8

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.

1

4 Answers 4

11

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
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

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'."
    }
}
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .