Archive: Add task using schtasks from nsis


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


Try "$INSTDIR\MyApp.exe"?


Same result


Example @ http://www.microsoft.com/resources/d....mspx?mfr=true uses quoted path so it should be supported...


It should be, but it seems not.

Why don't you give it a small try. You will find out.


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.

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.


I guess GetFullPathName /SHORT is the answer here. Thanks Demiller9


http://forums.winamp.com/showthread.php?t=283321