Roberto Madro R.
asked on
Restart a windows service from command line
I'm familiar with the "net start", "net stop", etc. to manage a service in windows, but do you know of a "restart" command?
ASKER
On a service that's behaving normally your suggestion works great, my problem is that I have a 3rd party app that has a deffective service that hangs between start and stop, so I can only restart (as the only logical step remaining), I can't stop the service because according to its status it's already "stopped" or sort-of stopped, and I can't restart it because it's already "sarted" or sort-of started, that's why I'm left with the "Restart" option. And I'm thinking since windows offers the "Restart" command, it must be known / available for use from the command line.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
EE pros come through again, many thanks, worked like charm.
ASKER
Can I follow up? Is that allowed.? if so, how can execute this against a remote server?
Thx
Thx
Use the following:
sc \\computername stop "ServiceName"
taskkill /s computername /f /fi "services eq ServiceName"
sc \\computername start "ServiceName"
Technically you should only ask one question per thread, but it's the season of goodwill :)
sc \\computername stop "ServiceName"
taskkill /s computername /f /fi "services eq ServiceName"
sc \\computername start "ServiceName"
Technically you should only ask one question per thread, but it's the season of goodwill :)
Using Alan's method you can use psexec
psexec \\servername /cmd /c net stop "ServiceName"
psexec \\servername /cmd /c taskkill /f /fi "services eq ServiceName"
psexec \\servername /cmd /c net start "ServiceName"
psexec \\servername /cmd /c net stop "ServiceName"
psexec \\servername /cmd /c taskkill /f /fi "services eq ServiceName"
psexec \\servername /cmd /c net start "ServiceName"
ASKER
You mighty kind Alan, Many thanks to both of you & happy new year.
Anytime.
Happy 2013 :)
Happy 2013 :)
net stop "Service Name" && net start "Service Name"
Not aware of a restart command line command.
http://technet.microsoft.com/en-us/library/cc736564(v=ws.10).aspx