How can I run a service which has status "stopped" using a cmd script?

link|improve this question

66% accept rate
you've asked 78 questions before, and I'm pretty sure almost all of them have been edited if not for grammar fixes, to remove the signatures. Please don't use them - faq. Please review the previous edits – Sathya Jul 26 '11 at 9:12
feedback

2 Answers

You can use sc.

sc query

Lists all running services installed on your computer.

sc query > c:\services.txt

Dumps the list of all running services into a file named services.txt in C:.

sc query state= inactive

Lists all stopped services installed on your computer.

sc query state= inactive > c:\dis_services.txt

Dumps the list of all stopped services into a file named *dis_services.txt* in C:.

sc start [service_name]

Starts a service called [service_name], for example:

sc start Spooler

Starts the Print Spooler service.

sc stop [service_name]

Stops a service called [service_name], for example:

sc stop Spooler

Stops the Print Spooler service.

link|improve this answer
feedback

If you're using Powershell then you can use the following commands:

get-service
start-service
stop-service

sc doesn't work in powershell straight away as it's aliased to a command called set-content.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.