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?
services.msc
.You should see:
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With