Skip to content
⌘ NSIS Forum Archive

Add in Scheduler

2 posts

luca89ct#

Add in Scheduler

Hi to everyone, I would to add my installed app into windows scheduler to startup every time that windows starts.

I tried this code, I haven't error on compile, but if I open scheduler I can't see my task.

Var /Global tempVar
StrCpy $tempVar $\"'$INSTDIR\$2\${MAIN_APP_EXE}'$\"
ExpandEnvStrings $0 %COMSPEC%
nsExec::ExecToStack '"$0" /C if 1==1 SchTasks /Create /SC ONLOGON /TN "ATask" /TR "$tempVar -j 1 -t 30 min"'
I need to use it on Windows 7 and over...

Could you help me, please?
Anders#
You never Pop the ExecToStack result.

Anyway, try
Var /Global tempVar
StrCpy $tempVar $\"'$INSTDIR\$2\${MAIN_APP_EXE}'$\"
ExpandEnvStrings $0 %COMSPEC%
/*nsExec::ExecToStack*/ MessageBox mb_ok '"$0" /C if 1==1 SchTasks /Create /SC ONLOGON /TN "ATask" /TR "$tempVar -j 1 -t 30 min"' 
and look at the final string. There is a "" but no ending "" and a single " in the middle there somewhere, does not seem right to me. First get it to work in cmd.exe and then move to NSIS.

I don't really understand why you need %COMSPEC% /c if 1==1 there at all, just execute schtasks.exe directly?

There is probably also code on the Wiki to create tasks without using external programs...