Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - No timeout for stop-service cmdlet?

Reply
 
Old 12-02-2008   #1 (permalink)
elcapitankyle


 
 

No timeout for stop-service cmdlet?

To perform some testing I have a service that intentionally takes 10 minutes
to shut down. When I stop the service from the Services mmc snap-in it
eventually times out and gives the error "Error 1053: The service did not
respond the start or control request in a timely fashion." This is what I'd
expect. However, when I try to stop the service using the stop-service cmdlet
it prints out the expected "WARNING: Waiting for service 'MyServiceName' to
finish stopping..." for the entire 10 minutes until the service actually
exits. It never times out or gives an error that the service might not be
responding.

My question is two fold. First, is there a way to specify the time out for
the stop-service cmdlet so that it gives an error if the service takes too
long to shut down or stops responding? Second, am I going about this in the
right way?

Here's my code:

#Verify status of service and stop it if running
$serviceInfo = get-service -displayName $serviceName
if($serviceInfo.status -eq "Stopped")
{
"Service is already stopped my friend"
exit 0
}

stop-service -displayName $serviceName



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
.net Windows Service Won't Start - Timeout .NET General
Controlling service restart timeout with WMI VB Script
Stop-Service cmdlet PowerShell
Windows Service Timeout in Vista Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46