Skip to content
⌘ NSIS Forum Archive

Add task using schtasks from nsis

9 posts

adnanshaheen#

Add task using schtasks from nsis

Hi All,

I am trying to add a task to task scheduler, using my nsis script.

ExecWait '$SYSDIR\schtasks.exe /Create /TN MyAppTask /SC ONSTART /TR "$INSTDIR"\MyApp.exe /RU System'

It adds a task but there is a problem with the task.
schtasks add the task with application name "$INSTDIR"\MyApp.exe
You people must know, here, $INSTDIR is "C:\Program Files".

Now the problem is, schtasks add the task with application "C:\Program" and arguments to the application as "Files\MyApp.exe". Which is definitely incorrect.

I want the application "C:\Program Files\MyApp.exe" to be the task.
Any help is highly appreciated.

Regards:-
Adnan
Anders#
Example @ http://www.microsoft.com/resources/d....mspx?mfr=true uses quoted path so it should be supported...
demiller9#
The page that Anders recommends has an example:
schtasks /change /tn Notepad /tr "c:\program files\Internet Explorer\iexplore.exe" /ru DomainX\Admin01

You should use their syntax with single quotes around the entire line for ExecWait to take the line as one parameter.
ExecWait '$SYSDIR\schtasks /create /tn MyAppTask /sc onstart /tr "$INSTDIR\MyApp.exe" /ru SYSTEM'
If that still doesn't work, try using the short file name version (8.3) of the path to your program. It won't need quotes that way.
adnanshaheen#
ok, thanks. But this doesn't work either.

How to get the short file name using the nsi script.
Because $INSTDIR can be changed by user during installation.
jpderuiter#
Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.