TechNet Magazine > Home > Tips > Windows 7 >  Use SchTasks.exe to Create and Manage Tasks
Tip: Use SchTasks.exe to Create and Manage Tasks


The Schtasks.exe command-line interface utility allows an administrator to create, delete, query, change, run, and end scheduled tasks on a local or remote system through the command shell. Here’s an overview of its syntax and parameters.

Follow Our Daily Tips

Tell Us Your Tips
Command Syntax
The SchTasks.exe command interface uses the following syntax:
SCHTASKS /<parameter> [arguments]

Command Parameters
The available parameters for SchTasks.exe are as follows:
  • /Create Creates a new scheduled task
  • /Delete Deletes the scheduled task(s)
  • /Query Displays all scheduled tasks
  • /Change Changes the properties of the scheduled task
  • /Run Runs the scheduled task immediately
  • /End Stops the currently running scheduled task
  • /? Displays a help message


Creating Tasks
The general syntax for Schtasks.exe is as follows:
SCHTASKS /Create [/S system [/U <username> [/P [<password>]]]] [/RU <username> [/RP <password>]] /SC schedule [/MO <modifier>] [/D <day>] [/M <months>] [/I <idletime>] /TN <taskname> /TR <taskrun> [/ST <starttime>] [/RI <interval>] [ {/ET <endtime> | /DU <duration>} [/K] [/XML <xmlfile>] [/V1]] [/SD <startdate>] [/ED <enddate>] [/IT] [/Z] [/F]

The following is an example command:
SCHTASKS /Create /S system /U user /P password /RU runasuser /RP runaspassword /SC HOURLY /TN rtest1 /TR notepad

Deleting Tasks
The general syntax for deleting a task is as follows:
SCHTASKS /Delete [/S <system> [/U <username> [/P [<password>]]]] /TN <taskname> [/F]

The following is an example command:
SCHTASKS /Delete /TN "Backup and Restore”

Running Tasks
The general syntax for running a task is as follows:
SCHTASKS /Run [/S <system> [/U <username> [/P [<password>]]]] /TN <taskname>

The following is an example command:
SCHTASKS /Run /TN "Start Backup"

Ending Tasks
The general syntax for ending a task is as follows:
SCHTASKS /End [/S <system> [/U <username> [/P [<password>]]]] /TN <taskname>

The following is an example command:
SCHTASKS /End /TN "Start Backup"

Querying Tasks
The general syntax for querying a task is as follows:
SCHTASKS /Query [/S <system> [/U <username> [/P [<password>]]]] [/FO <format>] [/NH] [/V] [/?]

The following is an example command:
SCHTASKS /Query /S system /U user /P password SCHTASKS /Query /FO LIST /V

Changing Tasks
The general syntax for changing a task is as follows:
SCHTASKS /Change [/S <system> [/U <username> [/P [<password>]]]] /TN <taskname> { [/RU <runasuser>] [/RP <runaspassword>] [/TR <taskrun>] [/ST <starttime>] [/RI <interval>] [ {/ET <endtime> | /DU <duration>} [/K]] [/SD <startdate>] [/ED <enddate>] [/ENABLE | /DISABLE] [/IT] [/Z] }

The following is an example command:
SCHTASKS /Change /RP password /TN "Backup and Restore"

From the Microsoft Press book The Windows 7 Resource Kit by Mitch Tulloch, Tony Northrup, Jerry Honeycutt, Ed Wilson, and the Windows 7 Team at Microsoft.
Looking for More Tips?

For more tips on Windows 7 and other Microsoft technologies, visit the TechNet Magazine Tips library.





Page view tracker