Problem
You want to schedule a task on a computer.
Solution
To manage scheduled tasks, use the schtasks.exe application. To view the list of scheduled tasks:
PS >schtasks
TaskName Next Run Time Status ==================================== ======================== ============= Defrag C 03:00:00, 5/21/2007 User_Feed_Synchronization{CA4D6D9C 18:34:00, 5/20/2007 User_Feed_Synchronization{CA4D6D9C 18:34:00, 5/20/2007
To schedule a task to defragment C: every day at 3:00 a.m.:
schtasks /create /tn "Defrag C" /sc DAILY ` /st 03:00:00 /tr "defrag c:" /ru Administrator
To remove a scheduled task by name:
schtasks /delete /tn "Defrag C"
Discussion
The example in the solution tells the system to defragment C: every day at 3:00 a.m.. It runs this command under the Administrator account, since the defrag.exe command requires administrative privileges. In addition to scheduling tasks on the local computer, the schtasks.exe application also allows you to schedule tasks on remote computers.
On Windows Vista, the schtasks.exe application has been enhanced to support event triggers, conditions, and additional settings.
For more information about the schtasks.exe application, type schtasks /?.