Batch files to start and stop ColdFusion

As I mentioned in the previous post, I recently wiped out everything and installed a fresh copy of Windows 7 on my personal laptop. After that, as any self-respecting ColdFusion professional would (kidding...sort of), I installed the Developer's edition of ColdFusion 9 application server and ColdFusion Builder. Also installed the MySQL database server, but that is sort of besides the point for the purposes of this post.

Anyway I was starting to feel pretty happy about my newly setup development environment when I noticed the memory usage slowly starting to go up. That reminded me that running an application server continuously in the background on a personal laptop is probably not a good idea. So initially I created a shortcut to Windows "Component Services" on my desktop and figured I would just start and stop the ColdFusion services as needed. But that was taking about 4 clicks and 80 seconds (yes, I counted) to start/stop all those services. Certainly did not seem to be the most efficient solution.

After some research I found that I could possibly write a batch file to accomplish this and that should speed things up. So that's what I ended up doing and it really does work delightfully well! I'm sure other people have done the same thing in the past but since I just discovered the wonders of batch files, I figured I'd post what I came up with (feel free to use this code if you want to):

Batch file to start ColdFusion:

view plain print about
1echo Starting ColdFusion 9
2sc start "ColdFusion 9 Application Server"
3sc start "ColdFusion 9 ODBC Agent"
4sc start "ColdFusion 9 ODBC Server"
5sc start "ColdFusion 9 Search Server"
6sc start "CF9Solr"
7sc start "ColdFusion 9 .NET Service"
8echo ColdFusion 9 Started
9pause

Batch file to stop ColdFusion:

view plain print about
1echo Stopping ColdFusion 9
2sc stop "ColdFusion 9 Application Server"
3sc stop "ColdFusion 9 ODBC Agent"
4sc stop "ColdFusion 9 ODBC Server"
5sc stop "ColdFusion 9 Search Server"
6sc stop "CF9Solr"
7sc stop "ColdFusion 9 .NET Service"
8echo ColdFusion 9 Stopped
9pause

Note: You will have to right-click and "Run as administrator" on Windows Vista or Windows 7 for this to work.

Funny story - I wrote this batch file, ran it, something flashed on the screen and went away and I had no idea what it did. It was actually pretty annoying at the time. So I started looking around to find out how to keep the output on the screen. In case you haven't figured it out yet, the "pause" command at the end does that. Took me more time to find that command than it took me to do everything else previously described combined. Hopefully this will save someone else some time :)

That's it for now folks!

Peace out.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Copyright © 2007-2012 All rights reserved apradhan.net | Feb 06, 2012
This site is running version 5.9.6.001 of BlogCFC created by Raymond Camden. Contact Anant Pradhan