I use a batch file to only start CF when I need it

I use a batch file to only start CF when I need it

Posted by Brad Wood
Aug 15, 2008 09:20:00 UTC
On my home PC I have the developer edition of ColdFusion 8 installed along with Apache Web Server and MySQL 5. Apache and MySQL are pretty lightweight, but ColdFusion can get a little bulky when it comes to memory. I don't use my personal Dev sites all the time, so I like to turn it all off when I'm not using it. I only have 1 gig of RAM in this PC after all.I went in and set the following services so their startup type was "manual"
  • ColdFusion 8 Application Server
  • ColdFusion 8 .NET Service
  • ColdFusion 8 ODBC Agent
  • ColdFusion 8 ODBC Server
  • ColdFusion 8 Search Server
  • MySQL5
  • Apache2
Then I created two batch files. startup_servers.bat
[code]net start "ColdFusion 8 Application Server"
net start "MySQL5"
net start "Apache2"
[code]net stop "ColdFusion 8 Application Server"
net stop "MySQL5"
net stop "Apache2"[/code]
What about the other ColdFusion 8 services? Well, I'm not using any of them right now, so I don't ever bother starting them. I placed shortcuts to both batch files in my quick launch bar with a catchy green arrow for startup and a little red "Ghost Busters" sign for shutdown. Now I can fire up all my dev stuff at the click of a button, and shut it all down with the same ease. On average, it can save me a couple hundred or so megs of free RAM.



Funny, that's exactly my setup for the last few years... you might wanna add some extra code to make it a bit more verbose and to be able to close the dos-prompt by pressing any key when it's finished.

See my batch file (I too don't need the other services daily so have most of them rem'ed out) below.

--------------start batch file-------------------

CLS @ECHO OFF ECHO. ECHO --------------------------------------------------------------------------- ECHO [Starting Local webserver and cf server] ECHO --------------------------------------------------------------------------- ECHO. net start "Apache2.2" net start "ColdFusion 8 Application Server" rem net start "ColdFusion 8 Search Server" rem net start "ColdFusion 8 ODBC Server" rem net start "ColdFusion 8 ODBC Agent" rem net start "MSSQLSERVER" rem net start "SQLSERVERAGENT" ECHO. ECHO ------- ECHO [DONE!] ECHO ------- ECHO. PAUSE

--------------end batch file-------------------

Steven Erat

Another advantage of starting ColdFusion at home from a batch file is that the server is running with your security credentials, allowing you to interact with other software programs on the machine. For example, I have a ColdFusion scheduled task that starts Logitech Studio about every half hour. Logitech Studio opens to the Motion Detection page and automatically triggers my webcam to start taking photos. Another scheduled task shuts Logitech down after 10 minutes, and yet another task does an upload of the last image to my public website.

When ColdFusion runs as a service it will not be allowed to interact with programs that run on the desktop in this way.

This could be an entry point to home automation, assuming you have the electrical chops to set up little servos on your blinds or coffee machine ;-)

todd sharp

Nice timing! I just wrote a few of these yesterday. A note to Vista users - make sure you create a shortcut to the batch file and check the 'Run As Administrator' box in the shortcut.

I only did CF, but I should probably add MySQL and IIS to the mix as well. Of course I'm not really sure why I bother since I have crap loads of RAM and I really don't do anything but develop on my laptop...

Brad Wood

@Steven: That home automatiion idea is kick butt! You could set up relays to control lights and such, but I'm not sure how you would tie it in to your PC. You would probably need a litle hardware, a serial port, and some assembly. Hmmm...


Stephen Collins' The ACME Guide (Apache ColdFusion, MySql, Eclipse), is a complete reference for setting up a development environment on mac or win. Stating on page 92, there are instructions on managing services with scripts.


Justin Carter

@Steven, the "Allow service to interact with desktop" option in the Log On tab of the service might allow that to work - if you didn't want to use a batch file :)

Another good tip for Vista users, if you still want to load these services automatically, is to change the service startup type to "Automatic (delayed start)" so that your system startup is faster and more responsive. That's how I currently have my system configured and it works great.

Site Updates

Entry Comments

Entries Search