Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
    
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

4 Answers 4

Here is the sample batch (*.BAT) file I use to start my local SQL Server instances (running as Windows services):

@Echo Off
NET START MSSQLSERVER
NET START MSSQL$SECONDARY
NET START MSSQL$CMS

Similarly, the following stops them all, one by one:

@Echo Off
NET STOP MSSQLSERVER
NET STOP MSSQL$SECONDARY
NET STOP MSSQL$CMS

So, use the NET START|STOP ServiceName command.

share|improve this answer

According to Larssend answer view this answer with SC description: http://stackoverflow.com/a/133926/1776789. For me it's works fine.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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