List and kill process on Windows Server

Well I’m forced to work with a Windows Server. For specific reasons, if you have an application that hangs up, you have the need to force an end to the process. This post shows the essential commands to kill a process on Windows Server with the command line.

First, start the cmd in Administrator Mode. For killing a process you need its process id (pid). With tasklist you get all processes and their respective pid. This example list only the program elasticsearch, the program, that hung up and I want to kill.

C:\Users\vinh>tasklist | grep elastic
elasticsearch-service-x64   106212 Services                   0  8'459'800 K

Kill the process with the command taskkill

C:\Users\vinh>taskkill /pid 106212
ERROR: The process with PID 106212 could not be terminated.
Reason: This process can only be terminated forcefully (with /F option).

Kill the process with force option

C:\Users\vinh>taskkill /pid 106212 /F
SUCCESS: The process with PID 106212 has been terminated.