If your computer is like mine you have a host of things installed:
- Database server
- Web server
- Version control server
- Mail server
By default I always set all these services to disabled so when I boot my computer I don't have to wait 30 minutes for everything to start up. And it's possible I may not be doing any application development so why have all that stuff running if I'm not using it?
But I also don't want to have to navigate into the Control Panel > Adminstrator Tools > Services each time I want to hack on some ColdFusion.
So let's automate things with some simple batch scripts and make our lives easier!
In our last post we wrote a simple script to automatically shut down our PC. Fire up your favorite text editor and let's create a few more files in the same directory:
net start "ColdFusion 8 Application Server" REM net start "ColdFusion 8 ODBC Agent" REM net start "ColdFusion 8 ODBC Server" REM net start "ColdFusion 8 Search Server" net start "World Wide Web Publishing" net start "IIS Admin" REM net start "Simple Mail Transfer Protocol (SMTP)" net start "OracleServiceXE"
Save this file as cf_start.bat (or whatever you'd like to name it). This will start all our application related services using the net start command. Not sure what the service is called? Open up the services window and look under the "Name" column - that's what you need to enter - use quotes if there are spaces in the service name as I did above with the ColdFusion related services. REM is like commented out code - it will not run. I normally don't run my mail server but if I need to I can remove the REM statement, run the script and mail will start.
To shutdown all our services I can simply use net stop (_save this as cf_stop.bat)_:
net stop "ColdFusion 8 Application Server" net stop "ColdFusion 8 ODBC Agent" net stop "ColdFusion 8 ODBC Server" net stop "ColdFusion 8 Search Server" net stop "World Wide Web Publishing" net stop "IIS Admin" net stop "Simple Mail Transfer Protocol (SMTP)" net stop "OracleServiceXE"
You'll notice I've removed all the REM statements - this will attempt to stop ALL services - and if it is already stopped - no harm done.
I also usually write a short script (cf_restart.bat) to bounce my ColdFusion servers:
net stop "ColdFusion 8 Application Server" net start "ColdFusion 8 Application Server"
So how can you use these?
I have these stored in a /scripts directory which I then tell my keyboard launcher (Find And Run Robot) to index. So I simply hit my shortcut key (ALT+SPACE) and enter cf_start... or cf_stop... and hit enter and viola everything cranks up/shuts down. You could also write a AutoHotkey script to run these with a keyboard shortcut. Or you could automate these with a scheduled task so they are started in the morning or maybe restarted while you are at lunch!
In our next post we'll examine some other common tasks we can automate using simple scripts.Go Top