Ever wander how to automate specific services starting and stopping ?
Well, at first the easiest part:
How to start or stop windows service from command-line ?use the tool "net" provided by windows:
net start [name of the service]
net start "SQL Server (MSSQLSERVER)"
We can also, stop the service with this tool:
net stop "SQL Server (MSSQLSERVER)"
Now the tricky part - how to START / STOP IIS site using command-line?
(Tested against IIS 6.0)
Microsoft provides some useful scripts that automate this work, and we can use them with the command-line tool cscript.exe. Let's assume we have the "Default Web Site" configure on the IIS and we want to start / stop it. Then open a command prompt and write down:
cscript /nologo %SystemRoot%\System32\IIsWeb.vbs /start "Default Web Site"
to start the site
cscript /nologo %SystemRoot%\System32\IIsWeb.vbs /stop "Default Web Site"
to stop the site.
You will find a number of other useful scripts and manual here.
All this helped me to make a batch files (.bat), which I use to start / stop services on my machine (I do not always need the services running and consuming memory and resources).