Programming Field

Schtasks /Change - DOS/Command Prompt Reference

Changes/Modifies the (registered) scheduled task settings. This is one of the commands (options) of Schtasks.

Syntax

schtasks[.exe] /Change [/S <remote-system> [/U <user-name> [/P [<password>]]]]
    /TN <task-name> [/TR <command>] [/ST <start-time>] [/RI <interval>]
    [{/ET <end-time> | /DU <duration>} [/K]]
    [/SD <start-date>] [/ED <end-date>] [/DELAY <delay-time>] [/IT]
    [/RU <user>] [/RP <password>] [/RL <level>] [/Z]
    [/ENABLE | /DISABLE] [/HRESULT]

Options

* At least one of /TR, /ST, /RI, /ET, /DU, /SD, /ED, /DELAY, /IT, /RU, /RP, /RL, and /Z must be specified (some settings must be changed).
* In Windows XP only /TR, /RU, or /RP can be specified.

/S <remote-system> Specifies the name of the computer (local/remote) where the task is registered. <remote-system> will be an IP address or hostname. If omitted, the local computer is the target.
/U <user-name> [/P [<password>]]

Specifies the login name and password when providing a computer name. You can specify a domain name in <user-name> (in the form of ‘domain\username’). If omitted, the user who executed this command will be used.

On ‘/P [<password>]’, if the entire ‘/P [<password>]’ is omitted, no password is set. If only ‘/P’ is specified (and ‘<password>’ is omitted), prompting the user to enter the password will occur (the entered password will be displayed as ‘*’ in the prompt).

/TN <task-name> Specifies the name of the task. If the task name contains space characters, you need to enclose it with ‘" "’. If the task exists within a folder hierarchy, include the path to the task as well.
/TR <command>

Specifies the command to execute. ‘<command>’ will be the executable filename followed by parameters.

When specifying parameters for the command, you need to enclose the entire command line with ‘" "’. However, if you want to include ‘"’ in the command line, you write it as ‘""’.

* The interpretation of ‘"’ is slightly special. When you write ‘""’, it means ‘include a " in the command line at that position’ + ‘start/end the " " enclosure’. For example, if you want to pass the command line ‘hoge "piyo piyo"’, you need to write it as ‘"hoge ""piyo piyo""’.

/ST <start-time> [Windows Vista or later] Specifies the start time of the task. ‘<start-time>’ will be the format ‘hh:mm’ (two digits for hours + ‘:’ + two digits for minutes) in 24-hour format. If omitted, the current time (at the time of executing the command) will be used. It cannot be specified when the schedule type (see ‘schtasks /Create’ option ‘/SC’) is ONSTART, ONLOGON, ONIDLE, or ONEVENT.
/RI <interval>

[Windows Vista or later] Specifies the interval in minutes for repeating the task. You can specify this only when the schedule type is DAILY, WEEKLY, MONTHLY, or ONCE (except ONCE, it will be repeated further for each schedule, for example, if MONTHLY triggers every month, it will be repeated at the specified interval with /RI). The task will be repeated until the time calculated by /ET or /DU. It cannot be specified when the schedule type is ONSTART, ONLOGON, ONIDLE, or ONEVENT.

If /ET or /DU is specified and /RI is omitted, the task will be executed at intervals of 10 minutes.

/ET <end-time> [Windows Vista or later] Specifies the end time (expiration) of the task. ‘<end-time>’ will be in the format ‘hh:mm’ (two digits for hours + ‘:’ + two digits for minutes) in 24-hour format. The end time must be later than the time when the task is executed for the first time, calculated from /ST (for example: if /ST is 16:25 and /RI is 1, then /ET must be after 16:27). It cannot be specified when the schedule type is ONSTART, ONLOGON, ONIDLE, or ONEVENT.
/DU <duration> [Windows Vista or later] Specifies the duration of the task repetition in minutes. This value must be greater than the value specified with /RI (or default to 10 if not specified). It cannot be specified when the schedule type is ONSTART, ONLOGON, ONIDLE, or ONEVENT.
/K [Windows Vista or later] When the end time calculated by /ET or /DU is reached, if the task is still running, a termination signal will be sent. In this case, the task execution log will indicate that it was forcibly terminated. It cannot be specified when the schedule type is ONSTART, ONLOGON, ONIDLE, or ONEVENT.
/SD <start-date> [Windows Vista or later] Specifies the date to start the task. ‘<start-date>’ will be the date in year-based date format according to the system settings. If omitted, the current date will be used. It cannot be specified when the schedule type is ONSTART, ONLOGON, ONIDLE, or ONEVENT.
/ED <end-date> [Windows Vista or later] Specifies the end date (expiration) of the task to be repeated. ‘<end-date>’ will be the date in year-based date format according to the system settings. It cannot be specified when the schedule type is ONCE, ONSTART, ONLOGON, ONIDLE, or ONEVENT.
/DELAY <delay-time> [Windows Vista or later] Specifies the delay time from when the trigger occurs to when the command is actually executed when the schedule type is ONSTART, ONLOGON, or ONEVENT. ‘<delay-time>’ will be the delay time in the format ‘mmmm:ss’ (for example: specify ‘0000:02’ for 2 seconds).
/IT

[Windows Vista or later] The task will only be executed if the user specified with /RU (or the user executing the command if not specified) is logged in. By default, the task is created with the same state as if /IT were specified.

Note that if SYSTEM is specified in /RU, /IT will be ignored.

* You cannot specify ‘/NP’ with ‘schtasks /change’. If you want to make a task run even when the user is not logged in, you need to recreate the task with ‘schtasks /Create’ (In that case, you can recreate it by outputting XML with ‘schtasks /Query’ and passing it to ‘schtasks /Create /XML’ with adding ‘/NP’).

/RU <user> Specifies the user to run the task. Built-in users such as ‘SYSTEM’ can also be used. If /NP in ‘schtasks /Create’ is not specified, the task will only run if this user is logged in.
/RP [<password>] Specifies the password for the user used to execute the task. If ‘<password>’ is omitted (when only /RP is specified), you will be prompted for the password. You can also specify only ‘/RP’ without specifying ‘/RU’ (in which case you change the password for the user already set for the task).
/RL <level> [Windows Vista or later] Specifies the level at which the task will run. ‘<level>’ must be either LIMITED (normal) or HIGHEST (highest privilege).
/Z

[Windows Vista or later] Deletes the task if it is not executed further after its execution. (It will be deleted one second later in practice.)

* If /Z is specified, /DU cannot be used, and /ET must be specified. (If /DU is specified, an error will occur: ‘The task XML is missing a required element or attribute. (45,4):EndBoundary:’)

/ENABLE [Windows Vista or later] Enables the task. If it's already enabled, a message indicating so will be displayed (the command itself will still succeed).
/DISABLE [Windows Vista or later] Disables the task. When disabled, it will not be executed even when its schedule timing arrives (if it was repeating with /RI, the executions will be skipped during the disablement period, but the repetitions will still be calculated; upon re-enabling, it will start executing again). If it's already disabled, a message indicating so will be displayed (the command itself will still succeed).
/HRESULT [Windows 10? or later] Changes the exit code of the Schtasks command to HRESULT. This is used when you want to perform detailed handling in case of errors.

Details

You can use ‘schtasks /Change’ to modify settings or enable/disable tasks that are already registered. If there are multiple items you want to change, you can specify the corresponding options all at once to modify the settings in a single command.

Some settings, such as the type of schedule (‘Daily’, ‘Monthly’, etc.), cannot be changed using ‘/Change’. In such cases, you either need to register the task again using ‘schtasks /Create’ (which can overwrite existing tasks with the ‘/F’ option), or you need to make the changes using the Task Scheduler GUI.

Samples

Sample

schtasks /change /tn "Hoge Piyo" /tr HogePiyo.exe

Modifies the program that the task ‘Hoge Piyo’ executes to ‘HogePiyo.exe’.

See also