However, you can open the Task Manager, right-click the process, and then click “End Task” to kill off the process. You can also terminate a specific process from the Details tab in the Task Manager. Sometimes you encounter issues with the Task Manager itself. For times like these, you may need to kill a process using the command line, which includes both the Command Prompt and Windows PowerShell. In this article, we show you multiple ways to kill a process in Windows using Command Line.
Why use the command line to terminate a process?
Although a normal user will not require killing processes using the command line, there are several use cases where command line tools are much better than their visual counterparts like the task manager. The following command line tools can be used in the following scenarios:
Troubleshooting: Some processes are simply stubborn. They just stop responding and refuse to die. In such a condition, killing them forcefully using the command line is an easier and safer option. System administration: If you are a sysadmin, you should be a fan of command line utilities. These tools save a lot of work and time. You can run these commands remotely throughout your network to troubleshoot systems remotely. Script Automation: If you are a developer and need to start or stop processes in Windows, you will need these command line tools for automation. Virus prevention: If your system gets infected with viruses, it will simply not let you kill the compromised processes, as they will respawn upon kill. In this case, you can automate a monitoring process where the process is killed as soon as it starts.
There are several other use cases, but these are the most common ones.
How to Kill a Process from Command Prompt
You can kill the process in cmd using the taskkill command. However, you must either know its Process Identifier (PID) or the name of the process before you can end it. To view and list the tasks and processes currently running on your computer, run the following command in an elevated Command Prompt: Note either the name under the Image name column or the PID number of the task you want to kill. These will be used in the cmdlets to kill the respective process. Once you have either the name or the PID of the task, use either of the following cmdlets to kill the process:
Kill task using process name in Command Prompt: Replace [ProcessName] with the name of the process. taskkill /IM “[ProcessName]” /F Kill process from Command Prompt using process name Kill task using PID in Command Prompt: Replace [PID] with the Process ID. taskkill /F /PID [PID] Kill process from Command Prompt using a process ID
If you are using earlier versions of Windows, like Windows 7, Windows Vista or even Windows XP, you can use tskill command, which is similar to taskkill but limited in functionality. You just need to provide the process ID to kill a task using tskill command: Replace [ProcessName] with the name of the process. Replace [PID] with the Process ID. Replace process-id with the actual process ID. For example,
How to Kill a Process from Windows PowerShell
Similar to the Command Prompt, you can also kill processes using PowerShell. But first, we must get the name or the process ID for the process to kill. To obtain a list of the running processes in PowerShell, run the following command in PowerShell with elevated privileges: From here, note down the process name or the PID (in the ID column) of the process that you want to kill, and then use it in the following commands: Note: Unlike the Command Prompt, Windows PowerShell shows no output once a process is killed.
Kill task using process name in PowerShell: Replace [ProcessName] with the name of the process. Stop-Process -Name “[ProcessName]” -Force Kill process from PowerShell using process name Kill task using PID in PowerShell: Replace [PID] with the Process ID. Stop-Process -ID [PID] -Force Kill process from PowerShell using a process ID
How to Kill a Process using WMIC
Windows Management Instrumentation Command-Line (WMIC) is a useful command line tool to perform administrative tasks especially for sysadmins and power users. You can terminate the process using wmic command. Replace [ProcessName] with the name of the process. Replace [PID] with the Process ID. Please note all the below mentioned commands will only work if you open Command Prompt, PowerShell or Terminal as an administrator. Replace process-id with the actual process ID. For example, You can also terminate the process using its name: Replace process-name with the actual process name. For example, If there are multiple processes by the same name, this command will kill all of them. For example, the above mentioned command will delete all instances with the name Skype.exe.
How to Kill a Process using SysInternals PsKills
PsKill is a tiny tool that comes with the PsTools Suite by SysInternals. This is a command-line tool used to kill processes, both locally and remotely on other computers on the network. Although it was designed for WindowsNT and Windows 2000 that did not include the other command-line tools (Killtask and Stop-Process), PsKill can still be used to end processes. Learn how to manage processes and services on remote computers. Use the following steps to download and use PsKill to kill tasks using the command line on a Windows computer: As you can see from the image above, the respective process will be killed, and the associated service or program will be terminated. Note down the name of the process that you want to kill.
Ending Thoughts
Even without the use of the Task Manager, there are multiple ways of killing a task or a process directly from the command line. You can even use these commands in scripts to end a Windows process. On top of that, you can choose whether to kill a process using its name or its PID. Either way, Command Prompt and Windows PowerShell can be used with both native and external commands for this purpose. Not only that, but you can also use these commands in Windows Terminal for the same purpose. If you are a sysadmin who wants quick and convenient methods to kill running processes, the given command line methods just might be the most convenient way of accomplishing it.