A typical Windows operating system runs a lot of processes in order to complete different tasks from UI to notepad, authentication to web surfing. The processes contain code and data about the task. In some cases, these tasks may become unresponsive or we may need to kill them. MS-DOS and PowerShell command prompts provide taskkill and Stop-Process commands in order to kill tasks via command-line interfaces.
List Processes via Command Line (CMD)
The first step to killing a process is listing the currently running processes. The
tasklist command can be used to list running processes with information like process name, process ID, session name, session number, etc. Especially the process name and the process ID is very useful to kill the process as they will be used as identifiers.
Typical windows run a lot of processes that are listed on multiple pages. The
more command can be used to navigate the task list page by page.
> tasklist | more
Kill Process with taskkill
Windows operating systems provide the
taskkill command in order to kill processes. The most stable way to kill a process is by providing its process ID or PID to the taskkill command. Also, the
/F option is provided to force killing the provided process ID. The process ID is provided with the
/PID parameter. The syntax of the taskkill command is as below.
taskkill /F /PID PROCESS_ID
- PROCESS_ID is the process ID that will be killed.
> taskkill /F /PID 3421
Kill Process with Process Name Using taskkill
The task kill command can be also used to kill processes with their name. The processes are generally named with the same of their executable files. The
/IM parameter is used to kill the process with its name. But keep in mind that some processes are created from the same executable multiple times which makes multiple processes with the same name. This action kills all processes with the same name.
> taskkill /F /IM "chrome.exe"
Kill Process with Stop-Process In PowerShell
PowerShell is a next-generation Windows command-line interface that provides a lot of features. The
Stop-Process command can be used in PowerShell in order to kill the process. The Stop-Process command syntax is like below.
Stop-Process -ID PROCESS_ID -Force
- PROCESS_ID is the process ID that will be stopped or killed
- -Force is used to force killing in that process.
In the following example, we kill the process with the ID number “3421”.
PS> Stop-Process -ID 3421 -Force
Kill Process Using Process Name with Stop-Process In PowerShell
The Stop-Process command can be also used to kill a process with its name. The
-Name parameter is used to kill a process with its name.
PS> Stop-Process -Name chrome.exe -Force