How to kill a windows process from command prompt

Kill windows process using cmd

How to kill a windows process using command prompt

Once I had an issue during a windows update and the solution to it was to restart the Windows Update Service. But when I went ahead and tried to restart the windows service it put me into another problem. The Windows Update service resisted a restart and was stuck at “Stopping the service” in services window. The only option to this was to kill the service process and start it again. This is where I came across the taskkill command that can be used to kill a windows process. In order to kill the process I needed the PID of the process so I went straight to the Task Manager. But to add to my unlucky day there wasn’t any process called “Windows Update” in the processes tab.

Windows update service is also known a wuauserv. You can get the short name of any service using below command(Open command prompt as administrator):

Getting short name of a windows service:

sc GetKeyName <Service Name>


C:\Windows\system32>sc GetKeyName "Windows Update"
[SC] GetServiceKeyName SUCCESS
Name = wuauserv

Now that I had the short name of the service I used the “sc queryex” command to find the PID of the Windows Update Service(wuauserv) which is as follows:

Finding PID of a windows service:

sc queryex <Service Short Name>


C:\Windows\system32>sc queryex wuauserv

        SERVICE_NAME: wuauserv
        TYPE               : 20  WIN32_SHARE_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_PRESHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
        PID                : 1116
        FLAGS              :

Or we can also look for the wuauserv service in the Services tab of the Task Manager and get the PID of the process.

Task Manager > Services Tab

Task Manager > Services Tab

So now that we have the PID of the process we want to kill, we can use the below taskkill command to kill the process

Killing a Windows Process

taskkill /F /PID <PID>

In the above command /F means forcefully terminate the process if it tries to resist.


C:\Windows\system32>taskkill /F /PID 1116
SUCCESS: The process with PID 1116 has been terminated.

Dannng..!! Now we can start the stuck service and get back to work… 🙂

We can also use taskkill to kill a process by Image name (by using /IM <Image Name>.)

C:\>taskkill /F /IM notepad.exe
SUCCESS: The process "notepad.exe" with PID 13088 has been terminated.

We can also use taskkill to kill processes on a remote computer. To learn more about taskkill command type

taskkill /?

Also note that taskkill is a very powerful command so always be very careful while executing it.
Hope this blog helped you.. Let me know how and your experience with taskkill in the comments below.

OsGeek - Aditya

I am just a curious OsGeek who fiddles with the OS tech.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *