Every infracture admin need to know the steps to force stop or kill windows service stuck at stopping by pid using taskkill or powershell. Think about a situation, you are trying to stop a windows service but its stuck at stopping status. Means service stopping hung and not responding. In this case we need to force kill windows service either by using taskkill in command line (cmd) or by powershell. Follow the step by step commands to apply in cmd for force stop service windows server.
Run command prompt as an administrator and type taskkill help command as below. That will display parameter list like /S, /U, /P, /FI, /PID, /IM, /T, /F, /? and why these are used. You will find these parameters in the commands below.
kill windows service command line
taskkill /?


First step is to identify the “Service name” of windows service stuck at stopping. Let’s say windows update service stuck at stopping, then right click on the service and click on properties will show you the service name “wuauserv”. Alterenatively, you can run powershell command “Get-Service” to get windows service details. Run the below command in command prompt to get the PID of service.
sc queryex <service name>
sc queryex wuauserv


You can check the PID in “Task manager” under the the tab “Services”.

Next step is to kill windows service PID running below cmd in command prompt.
taskkill /f /pid [PID]
taskkill /f /pid 996

You will find the service is stopped after applying the command above. You can disable the serivce else apply the state as per your requirement.

You can kill processes from command prompt without knowing the PID by running the below command.
taskkill /F /FI "SERVICES eq wuauserv"

You can force stop a service running with particular user id using below cmd.
taskkill /F /FI "USERNAME eq Deviprasad"
cmd to task kill all windows services not respnding running as below.
taskkill /F /FI "status eq not responding"
You can kill services consuming more then a limit of memory usage following the command below.
taskkill /FI "memusage gt value"
taskkill /FI "memusage gt 220600"


Run the cmd as below to get list of tasks running in server.
tasklist

we can run the below cmd to kill task running in the server.
taskkill /F /IM taskmgr.exe

End task using powershell
We can use below powershell commands to kill windows service.
Stop-Process -ID ProcessID - Force
Stop-Process -ID 6196 - Force
Stop-Process -Name ProcessName -Force
Stop-Process -Name iexplorer -Force

powershell command to force kill services not responding.
Get-WmiObject -Class win32_service | Where-Object {$_.state -eq 'stop pending'}
Watch the video to get details step by step for better understanding.
Categories: administration, SharePoint 2019, sharepoint services, windows service, Work Process
You must be logged in to post a comment.