Schtasks Command to configure a scheduled tasks
Schtasks – A command or programs to execute a task periodically or at a specific time.
Syntax
schtaks Parameter1 Paramerer2
Parameter1
/Create | Creates a new scheduled task. |
/Delete | Deletes the scheduled task(s). |
/Query | Displays all scheduled tasks. |
/Change | Changes the properties of scheduled task. |
/Run | Runs the scheduled task on demand. |
/End | Stops the currently running scheduled task. |
/ShowSid | Shows the security identifier corresponding to a scheduled t ask name. |
Parameter2 (for /create)
/D | Specifies the day of the week to run the task. Valid values: MON, TUE, WED, THU, FRI, SAT, SUN and for MONTHLY schedules 1 – 31 (days of the month). Wildcard “*” specifies all days. |
/DELAY | 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 schedule types ONSTART, ONLOGON, ONEVENT. |
/DU | Specifies the duration to run the task. The time format is HH:mm. This is not applicable with /ET and for schedule types: ONSTART, ONLOGON, ONIDLE, ONEVENT. |
/EC | ChannelName Specifies the event channel for OnEvent triggers. |
/ED | Specifies the last date when the task should run. The format is mm/dd/yyyy. This is not applicable for schedule types: ONCE, ONSTART, ONLOGON, ONIDLE, ONEVENT. |
/ET | Specifies the end time to run the task. The time format is HH:mm (24 hour time) for example, 14:50 for 2:50 PM. This is not applicable for schedule types: ONSTART, ONLOGON, ONIDLE, ONEVENT. |
/F | Forcefully creates the task and suppresses warnings if the specified task already exists. |
/I | Specifies the amount of idle time to wait before running a scheduled ONIDLE task. Valid range: 1 – 999 minutes. |
/IT | Enables the task to run interactively only if the /RU user is currently logged on at the time the job runs. This task runs only if the user is logged in. |
/K | Terminates the task at the endtime or duration time. This is not applicable for schedule types: ONSTART, ONLOGON, ONIDLE, ONEVENT. Either /ET or /DU must be specified. |
/M | Specifies month(s) of the year. Defaults to the first day of the month. Valid values: JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC. Wildcard “*” specifies all months. |
/MO | Schedule type to allow schedule recurrence. |
/NP | No password is stored. The task runs non-interactively as the given user. Only local resources are available. |
/P | Specifies the password for the given user context. Prompts for input if omitted. |
/RI | Specifies the repetition interval in minutes. This is not applicable for schedule types: MINUTE, HOURLY, ONSTART, ONLOGON, ONIDLE, ONEVENT. Valid range: 1 – 599940 minutes. If ither /ET or /DU is specified, then it defaults to 10 minutes. |
/RL | Sets the Run Level for the job. Valid values are LIMITED and HIGHEST. The default is LIMITED. |
/RP | Specifies the password for “run as” user. To prompt for the password, the value must be either “*” or none. This password is ignored for the system account. |
/RU | Specifies the “run as” user account (user context) under which the task runs. For the system account, valid values are “”, “NT AUTHORITY\SYSTEM” or “SYSTEM”. |
/S | Specifies the remote system to connect to. If omitted the system parameter defaults to the local system. |
/SC | Specifies the schedule frequency. Valid schedule types: MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE, ONEVENT. |
/SD | Specifies the first date on which the task runs. The format is mm/dd/yyyy. Defaults to the current date. This is not applicable for schedule types: ONCE, ONSTART, ONLOGON, ONIDLE, ONEVENT. |
/ST | Specifies the start time to run the task. The time format is HH:mm (24 hour time) for example, 14:30 for 2:30 PM. Defaults to current time if /ST is not specified. This option is required with /SC ONCE. |
/TN | Specifies a name which uniquely identifies this scheduled task. |
/TR | Specifies the path and file name of the program to be run at the scheduled time. Example: C:\windows\system32\cmd.exe |
/U | Specifies the user context under which SchTasks.exe should execute. |
/V1 | Creates a task visible to pre-Vista platforms. Not compatible with /XML. |
/XML | Creates a task from the task XML specified in a file. Can be combined with /RU and /RP switches, or with /RP alone, when task XML already contains the principal. |
/Z | Marks the task for deletion after its final run. |
Parameter2 (for /Query)
/FO | Specifies the format for the output. Valid values: TABLE, LIST, CSV. |
/NH | Specifies that the column header should not be displayed in the output. This is valid only for TABLE format. |
/P | Specifies the password for the given user context. Prompts for input if omitted. |
/S | Specifies the remote system to connect to. |
/TN | Specifies the task name for which to retrieve the information, else all of them. |
/U | Specifies the user context under which schtasks.exe should execute. |
/V | Displays verbose task output. |
/XML | Displays task definitions in XML format. |
Parameter2 (for /Delete)
/P | Specifies the password for the given user context. Prompts for input if omitted. |
/S | Specifies the remote system to connect to. |
/TN | Identifies the scheduled task to run now. |
/U | Specifies the user context under which the schtasks.exe should execute. |
/F | Forcefully deletes the task and suppresses warnings if the specified task is currently running |
Parameter2 (for /Run, /End)
/P | Specifies the password for the given user context. Prompts for input if omitted. |
/S | Specifies the remote system to connect to. |
/TN | Identifies the scheduled task to run now. |
/U | Specifies the user context under which the schtasks.exe should execute. |
Example
This command will create a schedule to open Calculator every alternate day.
schtasks /create /tn “Caculator” /tr calc.exe /sc daily /mo 2
This command will create a schedule to open Calculator on every Friday.
schtasks /create /tn “Caculator” /tr calc.exe /sc Weekly /d fri
This command will create a schedule to open Calculator on 2nd day of Month.
schtasks /create /tn “Caculator” /tr calc.exe /sc Monthly /d 2
This command will create a schedule to open Calculator on 2nd day of Month at 10 AM.
schtasks /create /tn “Caculator” /tr calc.exe /sc Monthly /d 2 /st 10:00