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?
Roberto Madro R.Programmer AnalystAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Alan HardistyConnect With a Mentor Co-OwnerCommented:
You should be able to use the taskkill command to terminate a hung service:

So combined:

net stop "ServiceName"
taskkill /f /fi "services eq ServiceName"
net start "ServiceName"
Alan HardistyCo-OwnerCommented:
You can combine the two into one command to restart a service:

net stop "Service Name" && net start "Service Name"

Not aware of a restart command line command.
Roberto Madro R.Programmer AnalystAuthor Commented:
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.
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

becraigConnect With a Mentor Commented:
You can script this
Step 1 find the name of the service and query svcname
take the PID from the step and then run “taskkill /PID xxxx /F”

you can write this into a simple bat file and pass in the service name
Roberto Madro R.Programmer AnalystAuthor Commented:
EE pros come through again, many thanks, worked like charm.
Roberto Madro R.Programmer AnalystAuthor Commented:
Can I follow up?  Is that allowed.?  if so, how can execute this against a remote server?

Alan HardistyCo-OwnerCommented:
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 :)
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"
Roberto Madro R.Programmer AnalystAuthor Commented:
You mighty kind Alan, Many thanks to both of you & happy new year.
Alan HardistyCo-OwnerCommented:

Happy 2013 :)
All Courses

From novice to tech pro — start learning today.