Wednesday 14 July 2010

How to schedule a program using Windows Task Scheduler

If a program is required to be run on a recurring schedule, a simple way of achieving this is to provide an executable than runs the command from its Main method. The task schedule can be managed using the Windows Task Scheduler.

To create a scheduled task on Windows Vista:

1. Open the Task Scheduler (Control Panel > Administrative Tools > Task Scheduler).
2. Click Create Task.
3. In the General tab, set the name of the task, and optionally provide a description. Click Change User or Group and select the user account under which the program should run. (This account should have the appropriate privileges.) Select Run Whether User Is Logged On or Not.
4. On the Triggers tab, click New. In the Settings section set the schedule. Optionally select Stop Task if It Runs Longer than. Click OK.
5. On the Actions tab, click New. Click Browse and select the .exe in the location selected in Setup.
6. Optionally, if the program requires network access, on the Conditions tab, select Start Only if the Following Network Connection Is Available and select the network connection to the required network connection. This will prevent the program from running in the event of the network connection being unavailable.
7. On the Settings tab, select Run Task as Soon as Possible After a Scheduled Start Is Missed and If the Task Fails Restart Every options.
8. Click OK.