The command: "taskkill" is on Windows 12, 11, 10, .. , MS Server 2025, 2022, 2019, .. available
The examples for the command "taskkill"
Here are examples of using the
`taskkill` command in Command Prompt:
Example 1: Terminating an application by process name:
taskkill /IM notepad.exe
-
`/IM`: This parameter specifies the process name.
-
`notepad.exe`: The name of the process to be terminated (here: Notepad).
Example 2: Killing a process by process ID:
taskkill /PID 1234
-
`/PID`: This parameter specifies the process ID (PID).
-
`1234`: The process ID of the process to terminate.
Example 3: Force Quit an Application by Process Name:
taskkill /F /IM chrome.exe
-
`/F`: This parameter forces the process to terminate without asking for confirmation.
-
`/IM chrome.exe`: The name of the process to be force terminated (here: Chrome).
Example 4: Stopping all instances of an application by process name:
taskkill /IM explorer.exe /T
-
`/T`: This parameter terminates all subprocesses of the specified process.
-
`/IM explorer.exe`: The name of the process to be terminated (here: Explorer).
Example 5: Killing all processes of a specific user:
taskkill /F /FI "USERNAME eq username"
-
`/F`: This parameter forces the processes to terminate without confirmation.
-
`/FI "USERNAME eq username"`: This filter specifies that only processes of the specified user should be terminated.
Example 6: Ending processes on a remote computer:
taskkill /S remote computer /U username /P password /IM notepad.exe
-
`/S Remote Computer`: The name or IP address of the remote computer.
-
`/U username`: The username for authentication on the remote computer.
-
`/P password`: The password for authentication on the remote computer.
-
`/IM notepad.exe`: The name of the process to terminate on the remote computer.
Note that terminating processes can affect running applications and system health. Therefore, use the
`taskkill` command with caution and make sure you understand the implications, especially when force-killing processes (
`/F`).
Example 7: Stopping all instances of an application and starting a new instance:
taskkill /F /IM notepad.exe
start notepad.exe
-
`/F`: Forces the process to terminate without confirmation.
-
`/IM notepad.exe`: Stops all instances of Notepad.
-
`start notepad.exe`: Starts a new instance of Notepad.
Example 8: Stopping all instances of an application on a remote computer:
taskkill /S remote computer /U username /P password /IM notepad.exe
-
`/S Remote Computer`: The name or IP address of the remote computer.
-
`/U username`: The username for authentication on the remote computer.
-
`/P password`: The password for authentication on the remote computer.
-
`/IM notepad.exe`: Stops all instances of Notepad on the remote computer.
Example 9: Killing processes based on their status:
taskkill /FI "STATUS eq RUNNING" /F
-
`/FI "STATUS eq RUNNING"`: Filters processes by their status (in this case
"RUNNING").
-
`/F`: Forces the selected processes to terminate.
Example 10: Killing all instances of an application with a specific window title:
taskkill /FI "WINDOWTITLE eq MyApplication - Editor" /F
-
`/FI "WINDOWTITLE eq MyApplication - Editor"`: Filters processes by their window title.
-
`/F`: Forces the selected processes to terminate.
Example 11: Killing all processes of a specific user except your own:
taskkill /F /FI "USERNAME neq %USERNAME%"
-
`/F`: Forces the selected processes to terminate.
-
`/FI "USERNAME neq %USERNAME%"`: Filters processes by username, excluding your own username.
These examples show various use cases for the
`taskkill` command in batch files, ranging from simple application termination to more complex filtering options. Note that the command should be used with caution as terminating processes can impact running applications and system health.
"taskkill" Excerpt from Microsoft Windows Help
Microsoft Windows [Version 10.0.19045.3693]
(c) Copyright 1985-2023 Microsoft Corp.
C:\\WINDOWS>
TASKKILL [/S system [/U username [/P [password]]]]
[/F] [/T]
Description:
This command line tool can be used to end one or more processes.
Processes can be killed by the process id or image name.
Parameter List:
/S system Specifies the remote system to connect to.
/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.
/F Specifies to forcefully terminate
process(es).
/FI filter Displays a set of tasks that match a
given criteria specified by the filter.
/PID process id Specifies the PID of the process that
has to be terminated.
/IM image name Specifies the image name of the process
that has to be terminated. Wildcard '*'
can be used to specify all image names.
/T Tree kill: terminates the specified process
and any child processes which were started by it.
/? Displays this help/usage.
Filters:
Filter Name Valid Operators Valid Value(s)
----------- --------------- --------------
STATUS eq, ne RUNNING | NOT RESPONDING
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 User name in [domain\]user
format
MODULES eq, ne DLL name
SERVICES eq, ne Service name
WINDOWTITLE eq, ne Window title
NOTE: Wildcard '*' for the /IM switch is accepted only with filters.
NOTE: Termination of remote processes will always be done forcefully
irrespective of whether /F option is specified or not.
Examples:
TASKKILL /S system /F /IM notepad.exe /T
TASKKILL /PID 1230 /PID 1241 /PID 1253 /T
TASKKILL /F /IM notepad.exe /IM mspaint.exe
TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne untitle*"
TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /IM notepad.exe
TASKKILL /S system /U domain\username /FI "USERNAME ne NT*" /IM *
TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*"
Important information, tips for the "taskkill" command
On Windows, there are several ways to kill or monitor processes in addition to the
`taskkill` command. Here are some other approaches:
1.
Task Manager:
- The Task Manager (accessible by
`Ctrl + Shift + Esc` or
`Ctrl + Alt + Del` and selecting
"Task Manager") provides a graphical user interface to monitor and terminate processes.
2.
PowerShell:
- PowerShell offers advanced process management capabilities. For example:
Stop Process -Name notepad
3.
Resmon (Resource Monitor):
- Resource Monitor (start it by typing
`resmon` in the command prompt) provides detailed information about resource usage and allows processes to be terminated.
4.
Process Explorer:
- Process Explorer from Sysinternals (part of Microsoft) is an advanced tool that provides detailed information about running processes and allows terminating processes.
5.
Windows Management Instrumentation (WMI):
- WMI can be used for managing processes. For example, a PowerShell script can kill processes using WMI.
6.
Task Scheduling:
- You can use task scheduling to run programs or scripts at a specific time. This can be used to start or end processes.
7.
AutoHotKey:
- AutoHotKey is a scripting tool that allows you to create custom scripts to monitor and control processes.
8.
Control Panel - Administrative Tools - Computer Management:
- Computer management provides information about local users and sessions. You can log out users or disconnect sessions.
9.
Remote Procedure Call (RPC):
- For advanced use cases, you can use RPC to control processes on remote computers.
Each of these methods has its own advantages and disadvantages as well as specific use cases. The choice depends on the exact requirements and preferences. However, keep in mind that terminating processes carries risks, especially when they are system processes or critical applications.