Archive: Scheduling a tastk


Scheduling a tastk
I've read the post regarding scheduling a task found here:


http://forums.winamp.com/showthread.php?threadid=147686&highlight=Task

I am a little new to .dlls and such and have a few questions regarding this script. If I post here could someone possibly offer assistance. I've tried using the AT command which works if the user has permissions to do that, but in many cases the user cannot use the AT command to schedule events so the thread referencing the system dlls and such piqued my interest but I'm a little fuzzy on how to use it. The attached script in the above reference thread URL returns an error when I run it (it compiles, but returns an error when I execute the executable).

Thanks


The complete example is available at:

http://nsis.sourceforge.net/Scheduled_Tasks

If you're unable to make it work, attach what you've got so far, explain what you've tried and how it fails and someone will surely be able to help you.


Okay, I figured out how to change the times, etc. My only question now is what would one do to make this a silent operation without the MB. Can you simply delete

MessageBox MB_OK "Backup job Scheduled task creation result: $0"

and put silentinstall at the top of the script?

Thanks


Actually, now I'm confused. I can get the task to be scheduled, but not run. I believe I'm having difficulty understanding the following section. The program I want to execute resides in $TEMP and it is called backup.exe.... so what would the parameters be to run that? I've changed them as follows but although the task gets scheduled, it doesn't run. backup.exe does not need any additional parameters to run. I have set this to run silently.

Section "SiteSecureBackup"
SetOutPath $TEMP
push "My Task"
push "My Task Comment"
push "c:\$TEMP\My Task backup.exe"
push "c:\$TEMP:"
push "My Program Args"
push \
"*(&l2, &i2 0, \
&i2 2006, &i2 1, &i2 1, \
&i2 0, &i2 0, &i2 0, \
&i2 0, &i2 0, \
i 0, i 0, \
i 0, \
i 1, \
&i2 1, &i2 00, &i2 0, i 0, &i2 0) i.s"
Call CreateTask
Pop $0
result: $0"
SectionEnd


You've scheduled it to run on Jan 1, 2006. I think you've missed that date already.

$TEMP already has a drive letter. Don't put another drive letter in front of it.


Yes, I noticed that mistake and corrected both the drive letter and date shortly after posting, however, with the new settings I still receive an error. The schtasks command shows a task is scheduled but it fails to run. I am entering the correct credentials for the user and password. I am still confused over some of the values for the settings, i.e., : What is supposed to be put into the area where the original coder has placed "My Program Args"? Can this only run with the credentials of the logged in user? It compiles without a problem, shows that a task is scheduled, but fails to run. I have the "program_to_run.exe" in the Temp directory. I'm perplexed. Any assistance would be greatly appreciated.

Section "SiteSecureBackup"
SetOutPath $TEMP
push "MyTask"
push "My Task Comment"
push "C:\Documents and Settings\user\Local
Settings\Temp\MyTask program_to_run.exe"
push "C:\Documents and Settings\user\Local
Settings\Temp"
push "My Program Args"
push "*(&l2, &i2 0, &i2 2007, &i2 9, &i2 2, &i2 0,
&i2 0, &i2 0, &i2 23, &i2 45, i 0, i 0, i 0, i 1, &i2
1, &i2 0x2, &i2 0, i 0, &i2 0) i.s"
push "Username"
push "Userpassword"
Call CreateTask
Pop $0
MessageBox MB_OK "Backup job Scheduled task creation
result: $0"
SectionEnd

; eof
SectionEnd


"My Program Args" is a string that you use for any command line switches you need, or "" if you don't need any.

Your latest code sample shows the schedule is for Sep 2, 2007. Is that what you wanted to schedule?

Is your program called "program_to_run.exe" (what you said you want to run) or "MyTask program_to_run.exe" (as you have in the code sample)?

Don


Okay, thank you for your help and clarifying those settings. I can now get it to run using the credentials of the logged in user. But if I replace those credentials with "", it fails to run. Is that how it's supposed to be? Must it always run with the credentials of the logged in user?

Thank you