banner



How To Kill A Windows Service

How to manually kill a Windows service process that is stack at "Stopping" or "Starting" state? Well-nigh Windows administrators have faced a problem when they endeavour to kickoff/stop/restart a service, but it gets stuck with the Stopping (or Starting) condition. You won't exist able to finish this service from the Service direction panel (services.msc), since all command buttons for this service get inactive (grayed out). The easiest way is to restart Windows, but it is not always acceptable. Permit'due south have a look at alternative ways, which allows to forcefully kill a stuck Windows service or procedure without organisation reboot.

windows service stopping, starting, not responding

If within thirty seconds later on trying to finish the service, it doesn't stop, Windows displays this message:

Windows Could not cease the xxxxxx service on Local Estimator Error 1053: The service did not reply in a timely style.

The timeout that the Service Control Manager waits for a service to start or end can be changed by using the ServicesPipeTimeout registry parameter. If the service doesn't start inside the specified timeout, Windows sends an error to the Consequence Viewer (Event ID: 7000, 7009, 7011, a timeout was reached 30000 milliseconds). Yous can increment this timeout to 60 seconds, for example:

reg add HKLM\Organisation\CurrentControlSet\Control /v ServicesPipeTimeout /t REG_SZ /d 600000 /f

This is useful when starting/stopping heavy services that do not accept enough time to properly terminate all processes and close the files (for instance, MS SQL Server).

If yous try to cease such a service from the command prompt: net stop wuauserv, a bulletin appears:

The service is starting or stopping. Please try over again subsequently.

The service is starting or stopping. Please try again letter.

or:

Windows could not end the Service on Local Reckoner. [SC] ControlService Error 1061: The service cannot accept control messages at this time.

Contents:

  • How to Force Kill a Stuck Windows Service Using TaskKill?
  • Force Terminate a Stuck Windows Service with PowerShell
  • Analyzing the Expect Bondage on Hung Services Using ResMon
  • Killing a Hung Service Using Process Explorer

How to Force Kill a Stuck Windows Service Using TaskKill?

The easiest way to stop a stuck service is to use the built-in taskkill command-line tool. Commencement of all, y'all need to find the PID (process identifier) of the service. As an example, let'due south accept the Windows Update service. Its system name is wuauserv (yous can check the name in the service properties in the services.msc console).

Important. Be attentive. Forced termination of critical Windows services can result in BSOD or an unexpected system restart.

Run this control in the elevated control prompt (it is important, or access denied mistake volition announced):
sc queryex wuauserv
In our case, the PID of the wuauserv service is 9186.
To force kill a stuck process with the PID 9186, run the command:

taskkill /PID 9168 /F

stopping stuck windows service in cmd using taskkill

SUCCESS: The process with PID 9168 has been terminated.

This control will forcibly stop the service process. Now you can get-go the service with the sc start servicename control or through the service management panel

You can terminate a hung service more elegantly without manually checking the PID of the service process. The taskkill tool has the /FI selection, which allows you lot to utilise a filter to select the necessary services or processes. Y'all tin can kill a specific service with the command:

taskkill /F /FI "SERVICES eq wuauserv"

Or you can skip the service name at all and killing all services in a hung state with the control:

taskkill /F /FI "status eq non responding"

After that, the service that is stack in the Stopping condition should stop.

You can also apply the taskkill utility to forcefulness terminate the hang services on a remote reckoner:

taskkill /South mun-fs01 /F /FI "SERVICES eq wuauserv"

Force Finish a Stuck Windows Service with PowerShell

Yous tin can too apply PowerShell to strength the service to end. Using the following command, you can get a list of services in the Stopping state:

Get-WmiObject -Grade win32_service | Where-Object {$_.land -eq 'stop pending'}

Or in the Starting state:

Get-WmiObject -Class win32_service | Where-Object {$_.state -eq 'showtime pending'}

list of services with "Stop pending" status

The Stop-Procedure cmdlet allows terminating the processes of all found services. The following PowerShell script volition terminate all stuck service processes on Windows:

$Services = Become-WmiObject -Class win32_service -Filter "state = 'terminate pending'"
if ($Services) {
foreach ($service in $Services) {
endeavor {
Stop-Process -Id $service.processid -Force -PassThru -ErrorAction Stop
}
take hold of {
Write-Warning -Bulletin "Error. Error details: $_.Exception.Message"
}
}
}
else {
Write-Output "No services with 'Stopping'.condition"
}

powershell script to kill stuck service process

Y'all must employ the Get-CimInstance instead of the Become-WmiObject cmdlet in the new PowerShell Core half-dozen.x/7.10. Replace the first command of the script with:

$Services = Get-CimInstance -Grade win32_service | where-Object state -eq 'stop pending'

Analyzing the Expect Bondage on Hung Services Using ResMon

You tin can observe the process that caused the service to hang using the resmon.exe (Resource Monitor).

  1. In the Resource Monitor window, go to the CPU tab and find the hung service process;
  2. Select the item Analyze Await Chain from the context menu;Resource Monito analyze wait chain
  3. In the new window, you will most likely run across that your process is waiting for another procedure. End the process. If you are waiting for the svchost.exe or another organization process, yous don't need to terminate information technology. Endeavor to analyze the await chain for this process. Detect the PID of the process that your svchost.exe is waiting for and kill it.

Killing a Hung Service Using Process Explorer

Even the local administrator cannot terminate some processes that run nether the SYSTEM account. The fact is that the admin account simply hasn't permissions on some processes or services. To stop such a process (service), you need to grant permissions to the service (process) to the local Administrators group and and so kill them. To do this, we volition need two small tools: psexec.exe and ProcessExplorer (available on the Microsoft website).

  1. To offset the ProcessExplorer with the arrangement privileges (runas SYSTEM), use the command: PSExec -s -i ProcExp.exe
  2. In the Process Explorer process list, find the stuck service process and open its properties;
  3. Become to the Services tab, find your service and click the Permissions button;proccess explorer service permissions
  4. Grant the Full Control right in the service permissions for the Administrators grouping. Save the changes;granting full control permissions on windows service for admin
  5. Now try to finish the service procedure.

    Please note, that the permission on the service is granted temporarily until it is restarted. To grant permanent permissions on service follow the article Set permissions on a Windows service.

How To Kill A Windows Service,

Source: http://woshub.com/killing-windows-services-that-hang-on-stopping/

Posted by: olsonartabow.blogspot.com

0 Response to "How To Kill A Windows Service"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel