SteveLovell
Level 5

Batch file for Schedule Tasks

I have got a file in my installation that needs to be set as a scheduled task. I have written a sample batch file that will set a scheduled task to lauch the calculator..

schtasks.exe /create /sc daily /tn "calculator" /tr c:\windows\system32\calc.exe /st 14:15


This works fine, but because the file I want it to run is installed with the applciation, and because this location can be declared by the user I have a headache.

How do I get the task to run from [INSTALLDIR]Folder\Task.exe?

[CODE]schtasks.exe /create /sc daily /tn "ScheduledTask" /tr [INSTALLDIR]Folder\Task.exe /st 14:15[/CODE]

~
I am ok to get a batch file running, I just dont know how to get the value of INSTALLDIR into the batch file.
Labels (1)
0 Kudos
4 Replies
rrinblue22
Level 9

A text file content replacement functionality in IS might be helpful.
worth a try
0 Kudos
RobertDickau
Flexera Alumni

Could you run the executable directly instead of going through a batch file? If so, you can easily pass [INSTALLDIR] or other properties to be expanded into the command.
0 Kudos
SteveLovell
Level 5

Sorry Robert that has gone a little over my head at this point, I will have to do some more reading and then look at this issue again. I will look into using text replacment and going through an executable that can be passed [INSTALLDIR] and post my methods here when I understand a little more.

Thanks
0 Kudos
SteveLovell
Level 5

EDIT:
I have got a text file changes setting to alter %INSTALLDIR% to the [INSTALLDIR] value, and have now got this altering the text in the batch file by placing the file in include files, and match whole word set to no (as i know that %installdir% will not appear anywhere else).

schtasks.exe /create /sc daily /tn "ScheduledTask" /tr %INSTALLDIR%Folder\Task.exe /st 14:15


All working now. Thanks for helping both.
0 Kudos