There may be many instances when you might want to be able to control windows services in such a way that they do not automatically start when your machine boots.  On my workstation, I have both SQL Server 2008 and 2012 installed, and each of these can delay my computer’s boot-up procedure in Windows 7 as well as use resources while running – all while I may not be actively developing against them.

In other words, they’re slowing my computer down unnecessarily.

Wouldn’t it be smarter if I just had these SQL Server instances activated only when I needed them?

Net Start and Net Stop to the rescue.  Net is a command line utility used to stop and start Windows Services.  All you have to do is find out what services you want to start or stop and which order the commands must be given.  Remember, some services depend on others to be running so you don’t want to start a service when its prerequisite is not available.

For instance, here are the commands in my batch file for starting my SQL Server 2012 instance:

And to stop SQL Server 2012, the bath file commands are:

Note they are reversed. So how did I know which application to use as an argument?  For instance, how did I know to use mssql$ver2012 as an argument for net start?

If you go to the Control Panel and then Administrative Tools you’ll notice the Services icon; it’s the one that looks like a toothed gear.


Then scroll to the service you would like to manage.  In this case, SQL Server Analysis Services (2012), the main service for SQL Server 2012.  Notice mine has a manual start.


Open that and you should see a screen like this:


You should see a Service name.  This is the argument to use for Net Start and Net Stop.

Notice there is a dependencies tab at the top.  This is important; if there are any dependencies your service has, these must be started first, either because their startup type is automatic or because you issue the net start command to them first.

Once you have your batch file created, you can set your service to start manually (notice the Startup type drop down) and just call your batch file to manage your application, whether it’s SQL Server, MySQL, or any other application that runs as a Windows Service.

Good luck!


Like this post? Share it!