When you are working on the Windows OS, it is an important part of any system administrator to know how to a kill process using PowerShell.
When Windows operating system starts, it will create a process for each system service.
Windows assigns a unique PID “Process Identifier” for each process.
For example, when you open the firefox application, the operating system creates a process for that application.
There are several ways to kill a process in Windows operating system.
In this tutorial, we’ll show you how to kill a process using PowerShell in Windows environment. Learn other useful PowerShell commands with this cheat sheet.
Open a PowerShell Interface
To open a PowerShell interface, press Windows + R keys together on the keyboard (or click the Windows button and type in “run” and hit Enter button to bring up the run windows) and type the following in the Run box as shown below:
Next, press OK button to open a PowerShell interface as shown below:
Kill a Process with Taskkill
The basic syntax of Taskkill command to kill a process is shown below:
taskkill /F /PID process-number
taskkill /IM process-name /F
Next, open the PowerShell interface and run the following command to list all running processes and their PIDs:
tasklist | more
You should see the following screen:
If you want to terminate the application WordPad, you will need to kill the process of wordpad.exe and cmd.exe application by its PID or by its name.
To kill a wordpress.exe process by its PID (1180), run the following command:
taskkill /F /PID 1180
To kill a cmd.exe process by its name, run the following command:
taskkill /IM CMD.EXE /F
Note : It is necessary to open PowerShell as Administrator to kill the process.
Kill a process using PowerShell
The basic syntax to kill a procees with Stop-Process command in PowerShell as shown below:
Stop-Process -Name process-name -Force
Stop-Process -ID process-id -Force
To kill a process with PID 1856 run the following command:
Stop-Process -ID 1856 -Force
To kill a process with process name WordPad run the following command:
Stop-Process -Name wordpad -Force
Similarly, you can kill the process of Notepad and Firefox with the following command:
Stop-Process -Name notepad -Force
Stop-Process -Name firefox -Force
In the above tutorial, we’ve learned how to kill a process using a PowerShell in Windows. Feel free to ask me if you have any questions below in the comments section!