Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
Task Scheduler
 Schtasks.exe
Schtasks.exe

Applies to: desktop apps only

Enables an administrator to create, delete, query, change, run, and end scheduled tasks on a local or remote computer. Running Schtasks.exe without arguments displays the status and next run time for each registered task.

Creating a Task

The following syntax is used to create a task on the local or remote computer.


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]

Parameters

/S system

A value that specifies the remote computer to connect to. If omitted, the system parameter defaults to the local computer.

/U username

A value that specifies the user context under which Schtasks.exe should run.

/P [password]

A value that specifies the password for a given user context. If omitted, Schtasks.exe prompts the user for input.

/RU username

A value that specifies the user context under which the task runs. For the system account, valid values are "", "NT AUTHORITY\SYSTEM", or "SYSTEM". For Task Scheduler 2.0 tasks, "NT AUTHORITY\LOCALSERVICE", and "NT AUTHORITY\NETWORKSERVICE" are also valid values.

/RP [password]

A value that specifies the password for the user specified with the /RU parameter. To prompt for the password, the value must be either "*" or no value. This password is ignored for the system account. This parameter must be combined with either /RU or the /XML switch.

/SC schedule

A value that specifies the schedule frequency. Valid values are: MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONLOGON, ONIDLE, and ONEVENT.

/MO modifier

A value that refines the schedule type to allow for finer control over the schedule recurrence. Valid values are:

  • MINUTE: 1 - 1439 minutes.
  • HOURLY: 1 - 23 hours.
  • DAILY: 1 - 365 days.
  • WEEKLY: weeks 1 - 52.
  • ONCE: No modifiers.
  • ONSTART: No modifiers.
  • ONLOGON: No modifiers.
  • ONIDLE: No modifiers.
  • MONTHLY: 1 - 12, or FIRST, SECOND, THIRD, FOURTH, LAST, and LASTDAY.
  • ONEVENT: XPath event query string.
/D days

A value that specifies the day of the week to run the task. Valid values are: MON, TUE, WED, THU, FRI, SAT, SUN and for MONTHLY schedules 1 - 31 (days of the month). The wildcard character (*) specifies all days.

/M months

A value that specifies months of the year. Defaults to the first day of the month. Valid values are: JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, and DEC. The wildcard character (*) specifies all months.

/I idletime

A value that specifies the amount of idle time to wait before running a scheduled ONIDLE task. The valid range is 1 - 999 minutes.

/TN taskname

A value that specifies a name which uniquely identifies the scheduled task.

/TR taskrun

A value that specifies the path and file name of the task to be run at the scheduled time. For example: C:\Windows\System32\calc.exe.

/ST starttime

A value that specifies the start time to run the task. The time format is HH:mm (24-hour time). For example, 14:30 specifies 2:30PM. The default is the current time is /ST is not specified. This option is required wit the /SC ONCE argument.

/RI interval

A value that specifies the repetition interval in minutes. This is not applicable for the following schedule types: MINUTE, HOURLY, ONSTART, ONLOGON, ONIDLE, and ONEVENT. The valid range is 1 - 599940 minutes. If either the /ET or /DU parameters are specified, the default is 10 minutes.

Windows XP and Windows Server 2003:  This option is not available.
/ET endtime

A value that specifies the end time to run the task. The time format is HH:mm (24-hour time). For example, 14:50 specifies 2:50PM. This is not applicable for the following schedule types: ONSTART, ONLOGON, ONIDLE, and ONEVENT.

Windows XP and Windows Server 2003:  This option is not available.
/DU duration

A value that specifies the duration to run the task. The time format is HH:mm (24-hour time). For example, 14:50 specifies 2:50PM. This is not applicable with /ET and for the following schedule types: ONSTART, ONLOGON, ONIDLE, and ONEVENT. For /V1 tasks (Task Scheduler 1.0 tasks), if /RI is specified, then the duration default is one hour.

Windows XP:  This option is not available.
/K

A value that terminates the task at the end time or duration time. This is not applicable for the following schedule types: ONSTART, ONLOGON, ONIDLE, and ONEVENT. Either /ET or /DU must be specified.

Windows XP and Windows Server 2003:  This option is not available.
/SD startdate

A value that specifies the first date on which to run the task. The format is mm/dd/yyyy. This value defaults to the current date. This is not applicable for the following schedule types: ONCE, ONSTART, ONLOGON, ONIDLE, and ONEVENT.

/ED enddate

A value that specifies the last date that the task will run. The format is mm/dd/yyyy. This is not applicable for the following schedule types: ONCE, ONSTART, ONLOGON, ONIDLE, and ONEVENT.

/EC ChannelName

A value that specifies the event channel for ONEVENT triggers.

Windows XP and Windows Server 2003:  This option is not available.
/IT

A value that enables the task to run interactively only if the /RU user is currently logged on at the time the task runs. The task runs only if the user is logged on.

Windows XP and Windows Server 2003:  This option is not available.
/NP

A value that indicates that no password is stored. The task does not run interactively as the given user. Only local resources are available.

Windows XP and Windows Server 2003:  This option is not available.
/Z

A value that marks the task to be deleted after its final run.

Windows XP and Windows Server 2003:  This option is not available.
/XML xmlfile

A value that creates a task from an XML file. This parameter can be combined with /RU and /RP switches, or with the /RP switch alone when the task XML already contains the principal.

Windows XP and Windows Server 2003:  This option is not available.
/V1

A value that creates a task visible to Windows 2000, Windows Server 2003, and Windows XP platforms.

Windows XP and Windows Server 2003:  This option is not available.
/F

A value that forcefully creates the task and suppresses warnings if the specified task already exists.

Windows XP and Windows Server 2003:  This option is not available.
/RL level

A value that sets the run level for the task. Valid values are LIMITED and HIGHEST. The default is LIMITED.

Windows XP and Windows Server 2003:  This option is not available.
/DELAY delaytime

A value that specifies the wait time to delay the task after the trigger is fired. The time format is mmmm:ss. This option is only valid for schedule types ONSTART, ONLOGON, and ONEVENT.

Windows XP and Windows Server 2003:  This option is not available.
/?

A value that displays the help message for Schtasks.exe.

Remarks

When creating a task on a remote computer running on the Windows XP, Windows Server 2003, or Windows 2000 operating system, use the /V1 switch.

You cannot create a non-interactive remote Task Scheduler 1.0 task (create a task by not using the /IT switch and using the /V1 switch) if the remote computer has the File and Printer Sharing firewall exception enabled and the Remote Scheduled Tasks Management firewall exception disabled.

Deleting a Task

The following syntax is used to delete one or more scheduled tasks.


schtasks /Delete 
[/S system [/U username [/P [password]]]]
[/TN taskname] [/F]

Parameters

/S system

A value that specifies the remote computer to connect to. If omitted, the system parameter defaults to the local computer.

/U username

A value that specifies the user context under which Schtasks.exe should run.

/P [password]

A value that specifies the password for the given user context. If omitted, Schtasks.exe prompts the user for input.

/TN taskname

A value that specifies the name of the scheduled task to delete. The wildcard character (*) can be used to delete all tasks.

/F

A value that forcefully deletes the task and suppresses warnings if the specified task is running.

/?

A value that displays Help for Schtasks.exe.

Running a Task

The following syntax is used to immediately run a scheduled task.


schtasks /Run 
[/S system [/U username [/P [password]]]]
/TN taskname

Parameters

/S system

A value that specifies the remote computer to connect to. If omitted, the system parameter defaults to the local computer.

/U username

A value that specifies the user context under which Schtasks.exe should run.

/P [password]

A value that specifies the password for the given user context. If omitted, Schtasks.exe prompts the user for input.

/TN taskname

A value that specifies the name of the scheduled task to run.

/?

A value that displays Help for Schtasks.exe.

Ending a Running Task

The following syntax is used to stop a running scheduled task.

Note  To stop a remote task from running, ensure that the remote computer has the File and Printer Sharing and Remote Scheduled Tasks Management firewall exceptions enabled.


schtasks /End 
[/S system [/U username [/P [password]]]]
/TN taskname

Parameters

/S system

A value that specifies the remote computer to connect to. If omitted, the system parameter defaults to the local computer.

/U username

A value that specifies the user context under which Schtasks.exe should run.

/P [password]

A value that specifies the password for the given user context. If omitted, Schtasks.exe prompts the user for input.

/TN taskname

A value that specifies the name of the scheduled task to stop.

/?

A value that displays Help for Schtasks.exe.

Querying for Task Information

The following syntax is used to display the scheduled tasks from the local or remote computer.


schtasks /Query 
[/S system [/U username [/P [password]]]]
[/FO format | /XML] [/NH] [/V] [/TN taskname] [/?]

Parameters

/S system

A value that specifies the remote computer to connect to. If omitted, the system parameter defaults to the local computer.

/U username

A value that specifies the user context under which Schtasks.exe should run.

/P [password]

A value that specifies the password for the given user context. If omitted, Schtasks.exe prompts the user for input.

/FO format

A value that specifies the output format. The valid values are TABLE, LIST, and CSV.

/NH

A value that specifies that the column header should not be displayed in the output. This is valid only for TABLE and CSV formats.

/V

A value that displays verbose task output.

Note  If a task was scheduled to run only one time, then the displayed schedule information is "Scheduling data is not available in this format."

/TN taskname

A value that specifies the task name for which to retrieve the information. If no task name is specified, then information for all the tasks will be displayed.

Windows XP and Windows Server 2003:  This option is not available.
/XML

A value that is used to display the task definitions in XML format.

Windows XP and Windows Server 2003:  This option is not available.
/?

A value that is used to display the Help for Schtasks.exe.

Changing a Task

The following syntax is used to change how the program runs, or change the user account and password used by a scheduled task.


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] }

Parameters

/S system

A value that specifies the remote computer to connect to. If omitted, the system parameter defaults to the local computer.

/U username

A value that specifies the user context under which Schtasks.exe should run.

/P [password]

A value that specifies the password for the given user context. If omitted, Schtasks.exe prompts the user for input.

/TN taskname

A value that specifies which scheduled task to change.

/RU runasuser

A value that changes the user name (user context) under which the scheduled task will run. For the system account, valid values are "", "NT AUTHORITY\SYSTEM", or "SYSTEM". For Task Scheduler 2.0 tasks, "NT AUTHORITY\LOCALSERVICE" and "NT AUTHORITY\NETWORKSERVICE" are also valid values.

/RP runaspassword

A value that specifies a new password for the existing user context or the password for a new user account. This password is ignored for the system account.

/TR taskrun

A value that specifies a new program that the task will run.

/ST starttime

A value that specifies the start time to run the task. The time format is HH:mm (24-hour time). For example, 14:30 specifies 2:30PM.

Windows XP and Windows Server 2003:  This option is not available.
/RI interval

A value that specifies the repetition interval, in minutes. The valid range is 1 - 599940 minutes.

Windows XP and Windows Server 2003:  This option is not available.
/ET endtime

A value that specifies the end time for the task. The time format is HH:mm (24-hour time). For example, 14:50 specifies 2:50PM.

Windows XP and Windows Server 2003:  This option is not available.
/DU duration

A value that specifies the duration to run the task. The time format is HH:mm (24-hour time). For example, 14:50 specifies 2:50PM. This is not applicable with the /ET parameter.

Windows XP and Windows Server 2003:  This option is not available.
/K

A value that terminates the task at the end time or duration time.

Windows XP and Windows Server 2003:  This option is not available.
/SD startdate

A value that specifies the first date on which to run the task. The format is mm/dd/yyyy.

Windows XP and Windows Server 2003:  This option is not available.
/ED enddate

A value that specifies the last date that the task will run. The format is mm/dd/yyyy.

Windows XP and Windows Server 2003:  This option is not available.
/IT

A value that enables the task to run interactively only if the /RU user is currently logged on at the time the task runs. The task runs only if the user is logged on.

Windows XP and Windows Server 2003:  This option is not available.
/RL level

A value that sets the run level for the task. Valid values are LIMITED and HIGHEST.

Windows XP and Windows Server 2003:  This option is not available.
/ENABLE

A value that enables the scheduled task. An enabled task can run, and a disabled task cannot run.

Windows XP and Windows Server 2003:  This option is not available.
/DISABLE

A value that disables the scheduled task from running.

Note  If a remote Task Scheduler 1.0 task is disabled by Schtasks.exe and the remote computer has the File and Printer Sharing firewall exception enabled and the Remote Scheduled Tasks Management firewall exception disabled, then the task will not be disabled when read from a Task Scheduler 2.0 API.

Windows XP and Windows Server 2003:  This option is not available.
/Z

A value that marks the task to be deleted after its final run.

Windows XP and Windows Server 2003:  This option is not available.
/DELAY delaytime

A value that specifies the wait time to delay the running of the task after the trigger is fired. The time format is mmmm:ss. This option is only valid for tasks with the schedule types ONSTART, ONLOGON, and ONEVENT.

Windows XP and Windows Server 2003:  This option is not available.
/?

A value that displays the Help message for Schtasks.exe.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

 

 

Send comments about this topic to Microsoft

Build date: 2/7/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Stop the existing instance      dean70   |   Edit   |   Show History
There doesnt seem to be an option to select 'Stop the existing instance' rule that is available from the UI. If you are running an OnLogon task as a System user account, it fails unless this option is selected.How do you do this with schtasks.exe?
Tags What's this?: Add a tag
Flag as ContentBug
Batch file is not terminating when i terminate the task in windows server 2008 R2.      Venkata Raja   |   Edit   |   Show History
I have written java -jar daemon.jar <params> in batch file and executed the batch file using task scheduler. When i terminate the task status shown as terminated successfully in task scheduler. But still the batch file is executing in the background and generating the logs. Can any one please help me regarding this?
Tags What's this?: Add a tag
Flag as ContentBug
Date Format Warning!      preon   |   Edit   |   Show History
For switches specifying dates, /sd and /ed, documentation says "The format is mm/dd/yyyy." This is NOT true for all environments as this seems to depend on regional settings. The alternative is "yyyy/mm/dd" and wrong format will FAIL the command. I detected this behavior when my MSI installer started failing on some machines...
Tags What's this?: Add a tag
Flag as ContentBug
Configure for parameter for OS      glspecter   |   Edit   |   Show History
Is there a schtasks.exe parameter to configure for a particular set of operating systems?
Currently tasks created with schtasks.exe default to Windows Vista, Windows Server 2008, and it would be preferable in my case to set them to run on Windows 7, Windows Server 2008 R2.
Tags What's this?: Add a tag
Flag as ContentBug
Forum?      Hetzi   |   Edit   |   Show History
Is there a forum for schtasks.exe or task scheduling?
Tags What's this?: Add a tag
Flag as ContentBug
When do ONLOGON scheduled tasks actually run?      Hetzi   |   Edit   |   Show History
Before, during or after the logon script?
Tags What's this?: Add a tag
Flag as ContentBug
Seem to be lots of properties schtasks won't set      DeSoto2011   |   Edit   |   Show History
"/ET endtime ... For example, 14:50 specifies 2:50PM."
"/DU duration ... For example, 14:50 specifies 2:50PM."

DU is supposed to be a duration. So how come it specifies a time of day, rather than a time interval? What is the difference between /ET and /DU?

No option that sets the "Stop Task If Runs X Hours and X Mins" value?
No option that sets the "Comment" value?
No option that sets "Start In"?
No option that sets "Power Management"?
Tags What's this?: Add a tag
Flag as ContentBug
ERROR: Value for '/tr' option cannot be more than 261 character(s).      Orr Dromi   |   Edit   |   Show History
Is there a way to pass the 261 chars limit?
I need to start the SQL Server replmerg.exe utility, which has a very long list of parameters. Including the path it is about 350 characters long.
Tags What's this?: Add a tag
Flag as ContentBug
ERROR: Value for '/tr' option cannot be more than 261 character(s).      Orr Dromi   |   Edit   |   Show History
Is there a way to pass the 261 chars limit?
I need to start the SQL Server replmerg.exe utility, which has a very long list of parameters. Including the path it is about 350 characters long.
Tags What's this?: Add a tag
Flag as ContentBug
/sc onstart but file doesn't start      Monkeyy   |   Edit   |   Show History
I've got a question. i used: schtasks /create /tn test /tr (path) /sc onstart . I runned as admin, all worked, and the tasked was created. Then I restarted my computer and the file doesn't start... and in schtasks it says: "Nicht gestartet" / "not started" ... where is the fault?
Thanks... (and sry for the question...)
Tags What's this?: Add a tag
Flag as ContentBug
try to modify the Task Settings      www.ceng.de ... Thomas Lee   |   Edit   |   Show History
Unfortunatly there seems to be no possibility to change the Setting Section in the XML file when using Commandline Arguments.

My Tasks will not work if the Notebook is on battery, because I create the Task by using a batch file and therefore I can´t change the Setting: &;;lt;DisallowStartIfOnBatteries&;;gt;false&;;lt;/DisallowStartIfOnBatteries&;;gt;

Bug, Feature?

[tfl - 28 08 10] Hi - and thanks for your post.You should post questions like this to the MSDN Forums at http://forums.microsoft.com/msdn. You are much more likely get a quick response using the forums than through the Community Content.

For specific help about:
.Net Development : http://social.msdn.microsoft.com/Forums/en-US/category/visualstudio
Open Specifications : http://social.msdn.microsoft.com/Forums/en-US/category/openspecifications
SharePoint 2010 : http://social.msdn.microsoft.com/Forums/en-US/category/sharepoint2010
SQL : http://social.msdn.microsoft.com/Forums/en-US/category/sqlserver
Visual Studio : http://social.msdn.microsoft.com/Forums/en-US/category/visualstudio
/TR Taskrun Option, single quotes are converted to double quotes      Chris P_   |   Edit   |   Show History
BUG or By Design?

If creating a scheduled task from the command line, any single quotes that exist inside the /TR switch quotes are converted from single quotes into double quotes. This might be convenient for some that don't know how to enter an escaped double quote, but it is quite annoying the following case where trying to execute a SQL stored procedure.

schtasks /create /TN MyJob /SC DAILY /ST 23:00 /V1 /TR "sqlcmd.exe -q \"exec sp_sqljob @database='NorthWind', @report=1\""

effectively becomes

schtasks /create /TN MyJob /SC DAILY /ST 23:00 /V1 /TR "sqlcmd.exe -q \"exec sp_sqljob @database="NorthWind", @report=1\""

which will fail to execute because SQL uses only single quotes for text vales. I couldn't figure out any way to escape the single quotes. Setting up the task using /XML works for Vista and higher but not for XP.


Note that this is a breaking change from XP/2003 where the single quotes are preserved. The "bug" occurs in the operating systems with the new task scheduler, Vista, Win7, 2008.
Tags What's this?: Add a tag
Flag as ContentBug
Localized option names      Mithfindel ... Da Kordo   |   Edit   |   Show History
Please note that at least on Windows XP Professional Edition, the option names are localized in some countries. For instance, the French and English versions will use the /DAILY switch, whilst in German the very same switch will be known as /TÄGLICH

This effectively prevents the same script from being used consistently across Windows XP versions.

this is also true for Italian and for the "AT" scheduling command.
Tags What's this?: Add a tag
Flag as ContentBug
What is this command for Win 2000 server?      akakk ... Da Kordo   |   Edit   |   Show History
What is the corresponding command line for Windows 2000 server. This command

schtasks

work only on XP and win 2003 servers.

thanks for your comments.

In win2000pro/server you can use the "AT" scheduling command.
Tags What's this?: Add a tag
Flag as ContentBug
Some answers      robsons   |   Edit   |   Show History
When scheduling a task that executes a file where the path or file name has spaces you need to use escaped double quotes ( \" ) around the <path>\<filename> and regular double quotes around the entire command itself. So to open c:\test.doc using MS Word structure your command as follows:

schtasks /create /tn "My App Job1" /tr "\"C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE\" C:\text.doc"
/sc DAILY /st 05:00:00 /ru <username> /rp
<password>

Scheduling a task to run interactively as SYSTEM can be tricky. Here is how to get SYSTEM to open C:\test.doc in MS Word at 11:00am using a scheduled task that uses AT.exe:

schtasks /create /tn "Interactive Job" /tr "\"C:\winxp\system32\at.exe\" \\127.0.0.1 11:00 /interactive \"C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE\" C:\test.doc" /sc DAILY /st 10:59:00 /ru SYSTEM

You can remove \\127.0.0.1 from the above command if you only want the command to run on the local machine. Its just in there as an example on how to run the command on another machine if desired.
Tags What's this?: Add a tag
Flag as ContentBug
What are the possible values for "Last Result"?      Jim Lancaster   |   Edit   |   Show History
I assume that "0" means "success". What other possible values can be returned for "Last Result"?
Tags What's this?: Add a tag
Flag as ContentBug
Why all those switches were remove to XP and Server2003      eam391   |   Edit   |   Show History
Recently I was trying to run an interactive .exe and could not deploy it to all my users because the /IT switch is not an option anymore..............
Tags What's this?: Add a tag
Flag as ContentBug
a wrong working folder of the schedule task that creating by command schtasks      Bontony   |   Edit   |   Show History
Hi,

I've to try to create a schedule task by schtasks command in windows XP,
after the command execution, I check the task detail and the working folder was a wrong value of the task
if the task command is in a folder under folder "c:\program files", the woring folder is 'c:',
does it a bug of schtasks or there are some things wrong in my schtasks execution.
the following is the command what I did:
SET SCHTASK_USER=username
SET SCHTASK_PWD=password
SET APP_HOME=C:\program files\myApp
SET BATCHJOB_HOME=%APP_HOME%\batchWoks
schtasks /create /tn "My App Job1" /tr "%BATCHJOB_HOME%\allExec.bat" /sc weekly /d MON,TUE,WED,THU,FRI /st 05:00:00 /ru %SCHTASK_USER% /rp %SCHTASK_PWD%

Bonb
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker