Old 3rd October 2018, 11:54   #1
luca89ct
Junior Member
 
Join Date: Jun 2018
Posts: 9
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.

code:
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?
luca89ct is offline   Reply With Quote
Old 3rd October 2018, 16:59   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,928
You never Pop the ExecToStack result.

Anyway, try
PHP Code:
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...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump