Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NET START <SERVICE> - how/where to get the service name?

I need to create a common script to restart service:

net stop <service>
net start <service>

Problem is that I don't know the name of the service. For example for "printer spooler" is the name "spooler".

How can I find the name for any service?

like image 445
gaffcz Avatar asked Aug 24 '11 08:08

gaffcz


2 Answers

  1. Start → Run
  2. Then type: services.msc.
  3. Double click on the service that you're interested in.

You should see:

enter image description here

like image 165
Tung Avatar answered Oct 18 '22 21:10

Tung


Use sc rather than net, since it boasts a lot more features. It was first introduced (IIRC) in Windows XP:

sc GetKeyName "printer spooler"

should print something like:

[SC] GetServiceKeyName SUCCESS  Name = Spooler

And you can then use that name in other commands, like sc start and sc stop.

like image 26
Damien_The_Unbeliever Avatar answered Oct 18 '22 20:10

Damien_The_Unbeliever