- NSIS Discussion
- Scheduled Tasks on Vista
Archive: Scheduled Tasks on Vista
Coolblu77
17th December 2007 15:25 UTC
Scheduled Tasks on Vista
I'm currently using the Scheduled Task Plugin http://nsis.sourceforge.net/Scheduled_Tasks,
this works very well on WindowsXP machines.
But on Vista machines the install wizard crashes the first time its ran, and the second time I get the returned value that the task already exists.
I have looked under C:\Windows\Tasks and found the tasks I'm trying to add are there with the .job extension.
But these do not work.
From reading MSDN I see that Vista uses Task Scheduler v2.0 where'as previous versions of Windows used Task Scheduler v1.0.
Does anyone have any script code or plugins that will create a task for Vista using the Task Scheduler v2.0 ?
Or am I going to have to read more about NSIS to try to do this myself (that's gonna take ages).
Thanks to anyone that can help.
kichik
17th December 2007 20:08 UTC
For a quick solution, it'd probably be simplest to write a plug-in that'd add the task. Base it on Examples\Plugin. If not, that script will have to be fixed so it works on Vista as well.
BSOD2600
8th March 2009 10:15 UTC
Ok, I realize it's an old thread...
Anyone made any headway on this issue yet? The script http://nsis.sourceforge.net/Scheduled_Tasks hasn't been updated nor any plugins made (that I'm aware of).
Anders
8th March 2009 21:45 UTC
The Vista v2 api has a flag called TASK_COMPATIBILITY_V1, so I assume the old api should still work. Could there be a bug with the code on the wiki?
Quoting AmitavaS - MSFT (http://blogs.msdn.com/amitava/) @ http://social.msdn.microsoft.com/For...-337d371d6756/
The ItaskScheduler 1.0 Interface is supported in Server 2008, and Vista. However, the tasks used by Vista and Server 2008 are accessed through the Itask Scheduler 2.0 Interface. Which means that manually scheduled tasks will not enumerate or appear when using the 1.0 interface.
This of course does not mean it actually works.
What if you try using at.exe from XP on Vista?
If it turns out that the v1 api is broken on Vista, then someone will need to write a v2 version
BSOD2600
8th March 2009 22:19 UTC
Originally posted by Anders
What if you try using at.exe from XP on Vista?
Yes, my NSIS code regarding creating a scheduled task, which works on Windows 2000, XP, 2003 does not appear to work on Vista x86.
Anders
8th March 2009 22:37 UTC
I was not talking about NSIS code there, I'm talking about AT.EXE that ships with XP. Take a copy of it from XP and try it on Vista
BSOD2600
8th March 2009 22:45 UTC
Oh the old AT command. I'm using the NSIS scheduled task code because the AT command doesn't provide me enough options/configuration that I need.
Anders
9th March 2009 03:01 UTC
well, at this point we just need to know if the v1 api works or not
BSOD2600
9th March 2009 04:19 UTC
Just tested. Yes, Vista x86 still comes with the AT command and it does work.
BSOD2600
9th March 2009 09:08 UTC
After some more digging, seems Vista has a new tool to manage the scheduled tasks: schtasks.
Also, since now one can export/import Scheduled tasks via XML files, I should be able to accomplish what I need. Export an XML file, use NSIS to modify various fields and then re-import via schtasks.
Anders
9th March 2009 20:06 UTC
Originally posted by BSOD2600
Just tested. Yes, Vista x86 still comes with the AT command and it does work.
I know it does, but I wanted you to COPY at.exe from XP and try that version on a Vista machine
BSOD2600
9th March 2009 21:11 UTC
Originally posted by Anders
I know it does, but I wanted you to COPY at.exe from XP and try that version on a Vista machine
Alright, copied over the XP AT.exe to Vista. Verified with sysinternals process monitor that it used the XP AT.exe to successfully create a scheduled task.
Coolblu77
11th March 2009 17:04 UTC
I probably should have replied to this ages ago.
I don't know if the Scheduled Task plugin has been changed, and I don't know anything about AT.exe (so I'm not really helping at all here).
But the way I got my tasks created was to get the Windows Version (http://nsis.sourceforge.net/Get_Windows_version), if it was "Vista" then I created the task using SchTasks.exe, else I used the Plugin.
SchTasks appears to be able to configure tasks with the same options that TaskScheduler in Control Panel can.
For anyone who comes across this thread and is interested, here's my SchTasks code to create a task that runs every day at a specified time:
StrCpy $strCmdLine "SCHTASKS /Create /RU UserName /RP Password /SC DAILY /TN TaskName \
/TR $\"'$INSTDIR\File.exe'$\" /ST $strStartHour:$strStartMin /SD 01/01/2008 /IT /F /MO 1"
nsExec::Exec '$strCmdLine'
Pop $0
StrCpy $cmdLineResult $0 1 0
StrCmp $cmdLineResult "0" Cmd2Success CmdFailed