5.7. Scheduling a Task
You want to schedule a task to run at a certain time or periodically.
Using a graphical user interface
From the Control Panel, open the Scheduled Tasks applet.
Double-click Add Scheduled Task.
Select the program you want to schedule to run.
Type a name for the task, select the frequency in which to run it, and click Next.
Enter the username and password of the user the task should run as and click Next.
If you want to go back and modify any of the settings for the task, check the box beside Open advanced properties and click Finish.
Using a command-line interface
On Windows Server 2003 or Windows XP, you can use the schtasks.exe command to schedule a task. The following command creates a task to run weekly at 1:00 AM:
> schtasks /create /SC WEEKLY /TN "Disk Space Checker" /TR "c:\perl\bin\perl.exe c:\scripts\diskchecker.pl" /ST 01:00
On Windows 2000, you can use the at.exe command to schedule tasks. This command is functionally equivalent to the previous schtasks.exe example:
> at 01:00 /next:Sunday "c:\perl\bin\perl.exe c:\scripts\diskchecker.pl"
The at command is available on Windows Server 2003 as well, but you are better off using schtasks.
' This code schedules a task to run every Sunday at 1:30AM. const MON = 1 const TUE = 2 const WED = 4 const THU = 8 const FRI = 16 const SAT = 32 const SUN = 64 ' ------ SCRIPT CONFIGURATION ------ strComputer = "." strCommand = "c:\perl\bin\perl.exe c:\scripts\diskchecker.pl" strStartTime ...