Programming Field

Schtasks /Delete - DOS/Command Prompt Reference

Deletes the registered scheduled task. This is one of the commands (options) of Schtasks.

Syntax

schtasks[.exe] /Delete [/S <remote-system> [/U <user-name> [/P [<password>]]]]
    /TN <task-name> [/F] [/HRESULT]

Options

/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.

You can also specify ‘*’ for <task-name>, in which case all tasks will be deleted. Please note that this includes tasks registered by the system, so caution is advised.

/F Forcefully deletes the task without displaying a prompt (warning).
/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

Deleting a task causes that the program specified in that task will no longer be executed. If the program is already running, deleting the task will not terminate the program itself.

You cannot delete multiple tasks simultaneously except for using ‘*’, which will delete all tasks. You cannot delete tasks grouped within a folder by specifying something like ‘/TN Piyo\*’, as it will result in a ‘task not found’ error. Additionally, you cannot delete a folder itself using ‘schtasks /delete’.

* To delete a folder itself, ensure it is empty and then execute ‘rd C:\Windows\System32\Tasks\<folder>’. However, note that the changes might not be reflected until you restart the computer.

Note that if the task creator and the current user do not match, you may not be able to delete the task unless you have strong permissions like administrator rights.

Samples

Sample

schtasks /delete /tr Hoge\Piyo /f

Deletes the task ‘Piyo’ inside the folder ‘Hoge’.

See also