Search Suggest

Start and stop batchfile services via a batchfile

Case
Constantly running all Microsoft SQL Services on your development desktop/laptop could be a little too much. Especially when you're not developing, but starting and stopping via the control panel is tiresome...

Solution
You can stop/start a service via the command (or even better, put it in a batchfile):
Syntax
NET START [service]
NET STOP [service]
NET PAUSE [service]
NET CONTINUE [service]

Key
service : The service name as shown in Control Panel, Services

Apparently it does not matter whether you use the Service name or the Display name. 
Service name or Display name















Start batchfile SQL 2005:
@ECHO OFF
NET START "SQL Server (MSSQLSERVER)"
NET START "SQL Server Agent (MSSQLSERVER)"
NET START "SQL Server Integration Services"
NET START "SQL Server Analysis Services (MSSQLSERVER)"
NET START "SQL Server Reporting Services (MSSQLSERVER)"

Stop batchfile SQL 2005:
@ECHO OFF
NET STOP "SQL Server (MSSQLSERVER)"
NET STOP "SQL Server Agent (MSSQLSERVER)"
NET STOP "SQL Server Integration Services"
NET STOP "SQL Server Analysis Services (MSSQLSERVER)"
NET STOP "SQL Server Reporting Services (MSSQLSERVER)"



Start batchfile SQL 2008:
@ECHO OFF
NET START "MSSQLSERVER"
NET START "SQL Server Agent (MsSqlServer)"
NET START "SQL Server Integration Services 10.0"
NET START "MSSQLServerOLAPService"
NET START "ReportServer"

Stop batchfile SQL 2008:
@ECHO OFF
NET STOP "MSSQLSERVER"
NET STOP "SQL Server Agent (MsSqlServer)"
NET STOP "SQL Server Integration Services 10.0"
NET STOP "MSSQLServerOLAPService"
NET STOP "ReportServer"

Note: It works the same for SQL 2012. Only the SSIS name has been changed to SQL Server Integration Services 11.0 and the rest of the names depend on the instance name you choose.

If you try to start a service that is already running you will get an error message like:
"The requested service has already been started. More help is available by typing NET HELPMSG 2182"

If you're running Windows Vista or Windows 7, your will have to start the batch file as an administrator or disable the User Account Control (UAC).
User Account Control (UAC)

Post a Comment