Microsoft KB Archive/814596

= How to use Schtasks.exe to Schedule Tasks in Windows Server 2003 =

Article ID: 814596

Article Last Modified on 12/3/2007

-

APPLIES TO


 * Microsoft Windows Server 2003, Datacenter Edition (32-bit x86)
 * Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)
 * Microsoft Windows Server 2003, Standard Edition (32-bit x86)
 * Microsoft Windows Server 2003, Web Edition
 * Microsoft Windows XP Professional for Itanium-based systems
 * Microsoft Windows Small Business Server 2003 Standard Edition
 * Microsoft Windows Small Business Server 2003 Premium Edition

-



For a Windows 2000 version of this article, see the following Knowledge Base article:

313565

IN THIS TASK

 * SUMMARY
 * Overview of the SchTasks.exe Tool
 * Syntax and Parameters
 * Schtasks /Create
 * Schtasks /Change
 * Schtasks /Run
 * Schtasks /End
 * Schtasks /Delete
 * Schtasks /Query
 * How to Create a Scheduled Task
 * How to Change a Scheduled Task
 * How to Run a Scheduled Task
 * How to End a Scheduled Task
 * How to Delete a Scheduled Task
 * How to Perform a Query of Scheduled Tasks
 * REFERENCES



SUMMARY
In Windows Server 2003, you can use Scheduled Tasks in Control Panel to create, delete, configure, or display scheduled tasks. You can also use Schtasks.exe to schedule tasks manually.

back to the top

Overview of the Schtasks.exe Tool
Schtasks schedules commands and programs to run periodically or at a specific time. Schtasks adds and removes tasks from the schedule, starts and stops tasks on demand, and displays and changes scheduled tasks.

back to the top

Syntax and Parameters
The following is a list of the syntax and parameters that you can use with Schtasks.exe:  

Schtasks /Create
Creates a new scheduled task.  Syntax:

schtasks /create/tn TaskName /tr TaskRun /sc schedule [/mo modifier] [/d day] [/m month[,month...] [/i IdleTime] [/st StartTime] [/sd StartDate] [/ed EndDate] [/du duration] [/s computer [/u [domain\]user /p password]] [/ru {[Domain\]User | &quot;System&quot;} [/rp Password]] /? Parameters:  /tn TaskName Specifies a name for the task. /tr TaskRun Specifies the program or command that the task runs. Type the fully qualified path and file name of an executable file, script file, or batch file. If you omit the path, Schtasks.exe assumes that the file is in the Systemroot\System32 folder. /sc schedule Specifies the schedule type. Valid values are MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE. /mo modifier Specifies how frequently the task runs in its schedule type. This parameter is required for a MONTHLY schedule. This parameter is valid, but optional, for a MINUTE, HOURLY, DAILY, or WEEKLY schedule. The default value is 1.</li> /d day Specifies a day of the week or a day of a month. Valid only with a WEEKLY or MONTHLY schedule.</li> /m month[,month...] Specifies a month of the year. Valid values are JAN - DEC and * (every month). The /m parameter is valid only with a MONTHLY schedule. It is required when the LASTDAY modifier is used. Otherwise, it is optional and the default value is * (every month).</li> /i IdleTime Specifies how many minutes the computer is idle before the task starts. Type a whole number from 1 to 999. This parameter is valid only with an ONIDLE schedule, and then it is required.</li> /st StartTime Specifies the time of day that the task starts in HH:MM:SS 24-hour format. The default value is the current local time when the command completes. The /st parameter is valid with MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, and ONCE schedules. It is required with a ONCE schedule.</li> /sd StartDate Specifies the date that the task starts in MM/DD/YYYY format. The default value is the current date. The /sd parameter is valid with all schedules, and is required for a ONCE schedule.</li> /ed EndDate Specifies the last date that the task is scheduled to run. This parameter is optional. It is not valid in a ONCE, ONSTART, ONLOGON, or ONIDLE schedule. By default, schedules have no ending date.</li> /du Duration Specifies a maximum length of time for a minute or hourly schedule in the HHHH:MM 24-hour format. After the specified time elapses, Schtasks does not start the task again until the start time happens again. By default, task schedules have no maximum duration. This parameter is optional and valid only with a MINUTE or HOURLY schedule.</li> /s Computer Specifies the name or IP address of a remote computer, with or without backslash characters. The default is the local computer.</li> /u [domain\]user Runs the command with the permissions of the specified user account. By default, the command runs with the permissions of the user who is logged on to the computer that is running Schtasks.</li> /p password Specifies the password of the user account that you specified in the /u parameter. This parameter is required when the /u parameter is used.</li> /ru {[Domain\]User | &quot;System&quot;} Runs the tasks with the permission of the specified user account. By default, the task runs with the permissions of the user who is logged on to the computer that is running Schtasks.</li> /rp Password Specifies the password of the user account that is specified in the /ru parameter. If you omit this parameter when you specify a user account, Schtasks.exe prompts you for the password and obscures the text you type. Tasks that run with permissions of the NT Authority\System account do not require a password and Schtasks.exe does not prompt for one.</li> /? Displays help at the command prompt.</li></ul>

</li></ul>

back to the top </li> 

Schtasks /Change
Changes one or more of the following properties of a task: <ul> The program that the task runs (/tr ).</li> The user account under which the task runs (/ru ).</li> <li>The password for the user account (/rp ).</li></ul>

<ul> <li>Syntax:schtasks /change /tn TaskName [/s computer [/u [domain\]user /p password]] [/tr TaskRun] [/ru [Domain\]User | &quot;System&quot;] [/rp Password]</li> <li>Parameters: <ul> <li>/tn TaskName Identifies the task to be changed. Type the task name.</li> <li>/s Computer Specifies the name or IP address of a remote computer with or without backslash characters. The default is the local computer.</li> <li>/u [domain\]user Runs the command with the permissions of the specified user account. By default, the command runs with the permissions of the user who is logged on to the computer that is running Schtasks.</li> <li>/p password Specifies the password of the user account that you specified in the /u parameter. This parameter is required when the /u parameter is used.</li> <li>/tr TaskRun Changes the program that the task runs. Type the fully qualified path and file name of an executable file, script file, or batch file. If you omit the path, Schtasks.exe assumes that the file is in the Systemroot\System32 folder. The specified program replaces the original program that is run by the task.</li> <li>/ru [Domain\]User | &quot;System&quot; Changes the user account for the task.</li> <li>/rp Password Changes the account password for the task. Type the new password.</li> <li>/? Displays help at the command prompt.</li></ul>

</li></ul>

back to the top </li> <li>

Schtasks /Run
Starts a scheduled task immediately. The run operation ignores the schedule, but uses the program file location, user account, and password that are saved in the task to run the task immediately. <ul> <li>Syntax:schtasks /run /tn TaskName [/s computer [/u [domain\]user /p password]] /?</li> <li>Parameters: <ul> <li>/tn TaskName Identifies the task. This parameter is required.</li> <li>/s Computer Specifies the name or IP address of a remote computer with or without backslash characters. The default is the local computer.</li> <li>/u [domain\]user Runs the command with the permissions of the specified user account. By default, the command runs with the permissions of the user who it logged on to the computer that is running Schtasks.</li> <li>/p password Specifies the password of the user account that you specified in the /u parameter. This parameter is required when the /u parameter is used.</li> <li>/? Displays help at the command prompt.</li></ul> </li></ul>

back to the top </li> <li>

Schtasks /End
Stops a program that was started by a task. <ul> <li>Syntax: schtasks /end /tn TaskName [/s computer [/u [domain\]user /p password]] /?

</li> <li>Parameters: <ul> <li>/tn TaskName Identifies the task that started the program. This parameter is required.</li> <li>/s Computer Specifies the name or IP address of a remote computer with or without backslash characters. The default is the local computer.</li> <li>/u [domain\]user Runs the command with the permissions of the specified user account. By default, the command runs with the permissions of the user who is logged on to the computer that is running Schtasks.</li> <li>/p password Specifies the password of the user account that is specified in the /u parameter. This parameter is required when the /u parameter is used. /? Displays help.</li></ul> </li></ul>

back to the top </li> <li>

Schtasks /Delete
Deletes a scheduled task. <ul> <li>Syntax:schtasks /delete /tn {TaskName | *} [/f ] [/s computer [/u [domain\]user/p password]] [/? ]

</li> <li>Parameters: <ul> <li>/tn {TaskName | *} Identifies the task being deleted. This parameter is required. <ul> <li>TaskName Deletes the named task.</li> <li>* Deletes all the scheduled tasks on the computer.</li></ul> </li> <li>/f Suppresses the confirmation message. The task is deleted without warning.</li> <li>/s Computer Specifies the name or IP address of a remote computer with or without backslash characters. The default is the local computer.</li> <li>/u [domain\]user Runs the command with the permissions of the specified user account. By default, the command runs with the permissions of the user who is logged on to the computer that is running Schtasks.</li> <li>/p password Specifies the password of the user account that you specified in the /u parameter. This parameter is required when the /u parameter is used.</li> <li>/? Displays help at the command prompt.</li></ul>

</li></ul>

back to the top </li> <li>

Schtasks /Query
Displays all the tasks that are scheduled to run on the computer, including those that are scheduled by other users: <ul> <li>Syntax:schtasks [/query] [/fo {TABLE | LIST | CSV}] [/nh ] [/v] [/s computer [/u [domain\]user/p password]]</li> <li>Parameters:[/query] The operation name is optional. Typing schtasks without any parameters performs a query.</li> <li>/fo {TABLE | LIST | CSV} Specifies the output format. TABLE is the default. /nh Omits column headings from the table display. This parameter is valid with the TABLE and CSV output formats.</li> <li>/v Adds advanced properties of the tasks to the display. Queries using /v should be formatted as LIST or CSV.</li> <li>/s Computer Specifies the name or IP address of a remote computer with or without backslash characters. The default is the local computer.</li> <li>/u [domain\]user Runs the command with the permissions of the specified user account. By default, the command runs with the permissions of the user who is logged on to the computer that is running Schtasks.</li> <li>/p password Specifies the password of the user account that is specified in the /u parameter. This parameter is required when the /u parameter is used.</li> <li>/? Displays help at the command prompt.</li></ul> </li></ul>

back to the top

How to Create a Scheduled Task
To create a scheduled task:
 * 1) Click Start, click Run, type cmd, and then click OK.
 * 2) At the command prompt, type net start, and then press ENTER to display a list of currently running services. If Task Scheduler is not displayed in the list, type net start &quot;task scheduler&quot;, and then press ENTER.
 * 3) At the command prompt, type schtasks /create /tn &quot; &quot; /tr c:\apps\  /sc   /st   /ed , and then press ENTER. Note that you may have to change the parameters for your situation. For example, you might type schtasks /create /tn &quot;My App&quot; /tr c:\apps\myapp.exe /sc daily /st 08:00:00 /ed 12/31/2004 This example schedules the MyApp program to run once a day, every day, at 8:00 A.M. until December 31, 2004. Because it omits the /mo parameter, the default interval of 1 is used to run the command every day.

back to the top

How to Change a Scheduled Task
To change a scheduled task:
 * 1) Click Start, click Run, type cmd, and then click OK.
 * 2) At the command prompt, type net start, and then press ENTER to display a list of currently running services. If Task Scheduler is not displayed in the list, type net start &quot;task scheduler&quot;, and then press ENTER.
 * 3) At the command prompt, type schtasks /change /tn TaskName [/s computer [/u [domain\]user /p password]] [/tr TaskRun] [/ru [Domain\]User | &quot;System&quot;] [/rp Password], and then press ENTER. Note that you may have to change the parameters for your situation. For example, to change the program that a task runs, type: schtasks /change /tn &quot;Application_Name&quot; /tr C:\File_Path\Application_Name.exe

back to the top

How to Run a Scheduled Task
To manually run a scheduled task outside its schedule:
 * 1) Click Start, click Run, type cmd, and then click OK.
 * 2) At the command prompt, type net start, and then press ENTER to display a list of currently running services. If Task Scheduler is not displayed in the list, type net start &quot;task scheduler&quot;, and then press ENTER.
 * 3) At the command prompt, type schtasks /run /tn TaskName [/s computer [/u [domain\]user /p password]], and then press ENTER. Note that you may have to change the parameters for your situation. For example, to run a task on the local computer, type schtasks /run /tn &quot; &quot;.

back to the top

How to End a Scheduled Task
To end a scheduled task:
 * 1) Click Start, click Run, type cmd, and then click OK.
 * 2) At the command prompt, type net start, and then press ENTER to display a list of currently running services. If Task Scheduler is not displayed in the list, type net start &quot;task scheduler&quot;, and then press ENTER.
 * 3) At the command prompt, type schtasks /end /tn TaskName [/s computer [/u [domain\]user /p password]], and then press ENTER. For example, to end the instances of a program that was started by a scheduled task on a local computer, type schtasks /end /tn &quot; &quot;.

back to the top

How to Delete a Scheduled Task
To delete a scheduled task:
 * 1) Click Start, click Run, type cmd, and then click OK.
 * 2) At the command prompt, type net start, and then press ENTER to display a list of currently running services. If Task Scheduler is not displayed in the list, type net start &quot;task scheduler&quot;, and then press ENTER.
 * 3) At the command prompt, type schtasks /delete /tn {TaskName | *} [/f] [/s computer [/u [domain\]user /p password]], and then press ENTER. For example, to delete all tasks scheduled for the local computer, type schtasks /delete /tn * /f.

back to the top

How to Perform a Query of Scheduled Tasks
To perform a query of scheduled tasks:
 * 1) Click Start, click Run, type cmd, and then click OK.
 * 2) At the command prompt, type net start, and then press ENTER to display a list of currently running services. If Task Scheduler is not displayed in the list, type net start &quot;task scheduler&quot;, and then press ENTER.
 * 3) At the command prompt, type schtasks /query, and then press ENTER. Output from this example displays a table of tasks that have been scheduled to run.

For more information about how to use Schtasks.exe, search for Schtasks.exe in Windo

After the specified time elapses, Schtasks does not start the task again until the start time recurs. By default, task schedules have no maximum duration. This parameter is optional and valid only with a MINUTE or HOURLY schedule.

ws Server 2003 Help.

back to the top

<div class="moreinformation_section">

MORE INFORMATION
For further information on the Schtasks command, go to the following Microsoft Web page:

http://technet.microsoft.com/en-us/library/bb490996.aspx

Keywords: kbmgmtservices kbhowtomaster KB814596

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.