What Command-line Tool Can You Use To Stop A Program That Is Hung?
How to manually kill a Windows service process that is stack at "Stopping
" or "Starting
" state? Most Windows administrators have faced a problem when they try to start/stop/restart a service, merely information technology gets stuck with the Stopping (or Starting) status. You won't exist able to stop this service from the Service direction panel (services.msc
), since all control buttons for this service become inactive (grayed out). The easiest way is to restart Windows, but it is not always acceptable. Let's take a wait at alternative ways, which allows to forcefully kill a stuck Windows service or process without organization reboot.
If inside 30 seconds afterwards trying to stop the service, it doesn't stop, Windows displays this message:
Windows Could non stop the xxxxxx service on Local Reckoner Error 1053: The service did not respond in a timely manner.
The timeout that the Service Command Managing director waits for a service to start or stop 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 (Upshot ID: 7000, 7009, 7011, a timeout was reached 30000 milliseconds). You can increase this timeout to lx seconds, for example:
reg add HKLM\Arrangement\CurrentControlSet\Control /5 ServicesPipeTimeout /t REG_SZ /d 600000 /f
This is useful when starting/stopping heavy services that do non accept enough fourth dimension to properly terminate all processes and close the files (for example, MS SQL Server).
If you try to stop such a service from the command prompt: net finish wuauserv
, a message appears:
The service is starting or stopping. Please endeavor over again afterward.
or:
Windows could not stop the Service on Local Computer. [SC] ControlService Error 1061: The service cannot take control messages at this time.
Contents:
- How to Forcefulness Kill a Stuck Windows Service Using TaskKill?
- Force Stop a Stuck Windows Service with PowerShell
- Analyzing the Look Chains on Hung Services Using ResMon
- Killing a Hung Service Using Procedure Explorer
How to Force Impale a Stuck Windows Service Using TaskKill?
The easiest mode to end a stuck service is to use the congenital-in taskkill control-line tool. First of all, y'all demand to discover the PID (process identifier) of the service. As an example, let's take the Windows Update service. Its system name is wuauserv
(you can check the proper noun 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 command in the elevated command prompt (it is important, or access denied error will appear):
sc queryex wuauserv
In our instance, 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
SUCCESS: The process with PID 9168 has been terminated.
This command will forcibly finish the service process. At present you can start the service with the sc start servicename
command or through the service direction console
You can finish a hung service more elegantly without manually checking the PID of the service process. The taskkill tool has the /FI option, which allows you to utilize a filter to select the necessary services or processes. You 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 "condition eq not responding"
After that, the service that is stack in the Stopping status should stop.
You can as well utilise the taskkill utility to force stop the hang services on a remote computer:
taskkill /S mun-fs01 /F /FI "SERVICES eq wuauserv"
Forcefulness Cease a Stuck Windows Service with PowerShell
You can also apply PowerShell to force the service to stop. Using the following control, you tin get a list of services in the Stopping country:
Become-WmiObject -Class win32_service | Where-Object {$_.country -eq 'end pending'}
Or in the Starting state:
Get-WmiObject -Class win32_service | Where-Object {$_.state -eq 'start pending'}
The Stop-Process cmdlet allows terminating the processes of all institute services. The following PowerShell script will terminate all stuck service processes on Windows:
$Services = Get-WmiObject -Class win32_service -Filter "land = 'stop pending'"
if ($Services) {
foreach ($service in $Services) {
attempt {
Finish-Procedure -Id $service.processid -Force -PassThru -ErrorAction Stop
}
take hold of {
Write-Warning -Message "Error. Error details: $_.Exception.Message"
}
}
}
else {
Write-Output "No services with 'Stopping'.status"
}
You must use the Get-CimInstance
instead of the Become-WmiObject
cmdlet in the new PowerShell Cadre six.10/vii.x. Replace the outset control of the script with:
$Services = Get-CimInstance -Class win32_service | where-Object country -eq 'terminate pending'
Analyzing the Wait Chains on Hung Services Using ResMon
You can detect the process that acquired the service to hang using the resmon.exe (Resource Monitor).
- In the Resource Monitor window, go to the CPU tab and find the hung service process;
- Select the detail Analyze Look Chain from the context menu;
- In the new window, you lot will about likely see that your process is waiting for another process. End the procedure. If yous are waiting for the svchost.exe or another system process, you don't need to terminate it. Endeavor to clarify the look chain for this process. Find the PID of the procedure that your svchost.exe is waiting for and kill information technology.
Killing a Hung Service Using Process Explorer
Even the local ambassador cannot stop some processes that run nether the Arrangement business relationship. The fact is that the admin account only hasn't permissions on some processes or services. To stop such a process (service), you demand to grant permissions to the service (process) to the local Administrators group and and so impale them. To do this, we will need two small tools: psexec.exe and ProcessExplorer (available on the Microsoft website).
- To first the ProcessExplorer with the system privileges (runas SYSTEM), use the command:
PSExec -due south -i ProcExp.exe
- In the Process Explorer process list, notice the stuck service process and open its properties;
- Go to the Services tab, find your service and click the Permissions button;
- Grant the Full Command right in the service permissions for the Administrators group. Save the changes;
- Now endeavour to end the service process.
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.
What Command-line Tool Can You Use To Stop A Program That Is Hung?,
Source: http://woshub.com/killing-windows-services-that-hang-on-stopping/
Posted by: washingtontured1978.blogspot.com
0 Response to "What Command-line Tool Can You Use To Stop A Program That Is Hung?"
Post a Comment