Talk:Scheduled Tasks

From NSIS Wiki
Jump to navigationJump to search

how hard would it be to do a deleteTask function? any help is appreciated

The article has been edited to show how to do this now.


All I see is a edit to remove the task before creating it. How do you add a option to the uninstaller to erase a task.? Need sample uninstall code.

Also when I try the code the popup says error but the task is installed. How do a create a task that runs every hr every day. I have tried adjusting 11 and 12 but its ignored.


Alternative to this function: schtask.exe + ExecWait

As this function is a real pain to use (I could not make it work in my script), I suggest anyone to use instead the schtask.exe command-line with the ExecWait macro to create a scheduled task. Since Windows Vista, you can even import xml files through the /xml flag, you could ship a MyTask.xml file inside your installer, extract to the $PLUGINSDIR dir previously created by the InitPluginsDir macro, modify its content as seen in this article and call ExecWait "schtasks /create /xml $PLUGINSDIR\MyTask.xml /tn $\"MyTask$\" /f" to finally create your task.

To obtain your xml, just create your task through the schtask.msc utility and export it through the appropriate menu. To confirm that the task was successfully created you should check its return code ($0).
-- Bugmenot (talk) 17:15, 1 September 2015 (UTC)

I advised in my previous comment to use the 'search and replace' function taken from this article, in fact you should not use any of the Text Files Manipulation Functions but the awesome TextReplace plugin instead that seems much more reliable and easier to use.
-- Bugmenot (talk) 15:39, 8 January 2016 (UTC)