Force Windows 7 Service to Stop

7

I have a crashed webserver which I should be able to shutdown with the following comamnd:

net stop https-myWebserver

However, I get the following error (on Windows 7 64-bit):

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

How can I force the service to stop/quit immediately? I'm hoping to avoid restarting the server.

David

Posted 2012-10-19T14:59:14.750

Reputation: 71

3

I found the answer via google, but I can't answer my own question for 8 hours so here is the link to the resolution: http://community.spiceworks.com/how_to/show/312-stop-a-hung-service

– David – 2012-10-19T15:07:48.983

Answers

10

You should be able to kill it via the Task Manager.

Right-click on taskbar -> Start Task Manager

If you can find it under the Processes tab:

Right click and select "End Process"

If you don't see it under Processes (or don't know which is the process for the service you want to kill),

While on the Processes tab

Check "Show processes from all users" in the lower left 
Then "View" menu and choose "Select Columns"
Check "PID" and hit OK
Go to the services tab to find the PID of the service you want to kill
Go back to Processes tab and Right-click -> End Process

jeremywho

Posted 2012-10-19T14:59:14.750

Reputation: 236

1

You need to find the PID for the service, then kill it.
Use this command to find the PID:

tasklist /FI "services eq https-myWebserver"

And once you have the PID number, kill the process from task manager, or using taskkill.

Full detail over here: http://www.itprostuff.com/articles/find-pid-service.html

ITProStuff

Posted 2012-10-19T14:59:14.750

Reputation: 389

0

If you have windows management framework 3.0 (powershell 3) or later, here's a Powershell one-liner.

Stop-Service -Name "https-myWebserver" -Force

There are also Start-Service and Restart-Service commands however the Start-Service command doesn't have a -force switch as it doesn't need one.

Junkiebev

Posted 2012-10-19T14:59:14.750

Reputation: 361

0

Powershell Advanced function from Mike Robbins blog

function Stop-PendingService {
<#
.SYNOPSIS
    Stops one or more services that is in a state of 'stop pending'.
.DESCRIPTION
     Stop-PendingService is a function that is designed to stop any service
     that is hung in the 'stop pending' state. This is accomplished by forcibly
     stopping the hung services underlying process.
.EXAMPLE
     Stop-PendingService
.NOTES
    Author:  Mike F Robbins
    Website: http://mikefrobbins.com
    Twitter: @mikefrobbins
#>
    $Services = Get-WmiObject -Class win32_service -Filter "state = 'stop pending'"
    if ($Services) {
        foreach ($service in $Services) {
            try {
                Stop-Process -Id $service.processid -Force -PassThru -ErrorAction Stop
            }
            catch {
                Write-Warning -Message "Unexpected Error. Error details: $_.Exception.Message"
            }
        }
    }
    else {
        Write-Output "There are currently no services with a status of 'Stopping'."
    }
}

Xalorous

Posted 2012-10-19T14:59:14.750

Reputation: 459