Taskkill command

Updated: 11/12/2023 by Computer Hope
taskkill command

The taskkill command allows a user running any version of Microsoft Windows from XP on to "kill" a task from a Windows command line by PID (process id) or image name. This command is similar to end tasking a program in Windows.

Availability

Taskkill is an external command that is available for the following Microsoft operating systems as taskkill.exe.

Tip

Windows XP Home editions utilize this command. Use the command tskill instead.

Taskkill syntax

Windows Vista and later syntax

TASKKILL [/S system [/U username [/P [password]]]] { [/FI filter] [/PID processid | /IM imagename] } [/T] [/F]
/S system Specifies the remote system of where to connect.
/U [domain\]user Specifies the user context under which the command should execute.
/P [password] Specifies the password for the given user context. Prompts for input if omitted.
/FI filter Applies a filter to select a set of tasks. Allows "*" to be used. ex. imagename eq acme* See below filters for additional information and examples.
/PID processid Specifies the PID of the process to be terminated. Use tasklist to get the PID.
/IM imagename Specifies the image name of the process to be terminated. Use the wildcard '*' to specify all tasks or image names.
/T Terminates the specified process and any child processes which were started by it.
/F Specifies to forcefully terminate the process(es).

Filters:

Name Operators Value
STATUS eq, ne RUNNING | NOT RESPONDING | UNKNOWN.
IMAGENAME eq, ne Image name.
PID eq, ne, gt, lt, ge, le PID value.
SESSION eq, ne, gt, lt, ge, le Session number.
CPUTIME eq, ne, gt, lt, ge, le CPU time in the format of hh:mm:ss.
hh - hours, mm - minutes, ss - seconds.
MEMUSAGE eq, ne, gt, lt, ge, le Memory usage in KB.
USERNAME eq, ne Username in [domain\]user format.
MODULES eq, ne DLL (dynamic-link library) name.
SERVICES eq, ne Service name.
WINDOWTITLE eq, ne Window title.

Note:

  1. Wildcard '*' for /IM switch is accepted only when a filter is applied.
  2. Termination of remote processes is done forcefully (/F).
  3. "WINDOWTITLE" and "STATUS" filters are not considered when a remote
    machine is specified.

Windows XP and earlier syntax

taskkill [/s Computer] [/u Domain\User [/p Password]]] [/fi FilterName] [/pid ProcessID]|[/im ImageName] [/f][/t]
/s computer Specifies the name or IP address of a remote computer (do not use backslashes). The default is the local computer.
/u domain\user Runs the command with the account permissions of the user specified by User or Domain\User. The default is the permissions of the current logged on user on the computer issuing the command.
/p password Specifies the password of the user account that is specified in the /u parameter.
/fi FilterName Specifies the types of process(es) to include in or exclude from termination. The following are valid filter names, operators, and values.

Name Operators Value
Hostname eq, ne Any valid string.
Status eq, ne RUNNING|NOT RESPONDING
Imagename eq, ne Any valid string.
PID eq, ne, gt, lt, ge, le Any valid positive integer.
Session eq, ne, gt, lt, ge, le Any valid session number.
CPUTime eq, ne, gt, lt, ge, le Valid time in the format of hh:mm:ss. The mm and ss parameters should be between 0 and 59 and hh can be any valid unsigned numeric value.
Memusage eq, ne, gt, lt, ge, le Any valid integer.
Username eq, ne Any valid username ([Domain\]User).
Services eq, ne Any valid string.
Windowtitle eq, ne Any valid string.
/pid processID Specifies the process ID of the process to be terminated.
/im ImageName Specifies the image name of the process to be terminated. Use the wildcard (*) to specify all image names.
/f Specifies that process(es) be forcefully terminated. This parameter is ignored for remote processes; all remote processes are forcefully terminated.
/t Specifies to terminate all child processes and the parent process, commonly known as a tree kill.
Tip

See the operator definition for full information about operators and eq, ge, gt, le, lt, and ne.

Taskkill examples

Tip

If you need to see a listing of all running tasks, use the tasklist command.

taskkill /f /im notepad.exe

Kills the open Notepad task.

taskkill /pid 9764

Kill the task with PID 9764. If successful, this command should give you a message similar to the example below.

SUCCESS: Sent termination signal to the process with PID 9764.