Justin Carter's madfellas.com

Running CF7 and CF8 Services with a batch file menu

As a follow up to my previous post on Running CF7 and CF8 simultaneously on IIS7 I thought I would share the batch file I use to manage the starting and stopping of the ColdFusion services and some other tips. Note that this mostly Vista specific stuff, including the batch file itself (it uses the 'choice' command which is different in Vista compared to previous versions of Windows).

When running both CF7 and CF8 on the same development machine I generally set all the services to Manual start-up and set only one of the ColdFusion Application Server services to Automatic (Delayed Start). Delayed Start is a new option in Vista that aims to keep your system snappier at boot up, so any services that are set to Delayed Start won't be started immediately during the boot process and will instead execute later when other services have had time to start and finish using time-critical resources.


cf-services


To manage the starting and stopping of the ColdFusion services I wrote a simple batch file that has a menu for selecting which service you want to start or stop. If you save the batch file as UserDocumentsscriptscf.bat it is easy to have quick access to the file by hitting the windows key and typing 'cf.bat'. You can then right click on the file and choose "Run as administrator" so that the process will have permission to start and stop services.


cf-batch-file


When the script is running you will be presented with a simple, straight forward menu.


cf-service-menu


Below is the full script if you would like to use it. It could be customised to add any other services you might want to start and stop such as MS SQL Server, MySQL, PostgreSQL, IIS, Apache, etc. Note: use the "view plain" or "copy to clipboard" links to easily copy the code, paste into Notepad, and save as cf.bat.

Enjoy!


@echo off
REM ColdFusion Services helper batch file, by Justin Carter
REM http://www.madfellas.com
REM 
REM This script is provided as is, with no warranty of any kind.
REM Use at your own risk :)
 
:menu
echo.
echo. 1) Start ColdFusion 8
echo. 2) Stop ColdFusion 8
echo.
echo. 3) Start ColdFusion MX 7
echo. 4) Stop ColdFusion MX 7
echo.
echo. Q) Quit
 
echo.
choice /c 1234Q /n /m " Choose a menu option:"
echo.
 
if Errorlevel 5 goto quit
if Errorlevel 4 goto stopcf7
if Errorlevel 3 goto startcf7
if Errorlevel 2 goto stopcf8
if Errorlevel 1 goto startcf8
goto quit
 
:startcf8
echo.
net start "ColdFusion 8 Application Server"
REM net start "ColdFusion 8 .NET Service"
REM net start "ColdFusion 8 ODBC Agent"
REM net start "ColdFusion 8 ODBC Server"
REM net start "ColdFusion 8 Search Server"
cls
echo.
echo. ColdFusion 8 Services started
echo.
goto menu
 
:stopcf8
echo.
net stop "ColdFusion 8 Application Server"
net stop "ColdFusion 8 .NET Service"
net stop "ColdFusion 8 ODBC Agent"
net stop "ColdFusion 8 ODBC Server"
net stop "ColdFusion 8 Search Server"
cls
echo.
echo. ColdFusion 8 Services stopped.
echo.
goto menu
 
:startcf7
echo.
net start "ColdFusion MX 7 Application Server"
REM net start "ColdFusion MX 7 ODBC Agent"
REM net start "ColdFusion MX 7 ODBC Server"
REM net start "ColdFusion MX 7 Search Server"
cls
echo.
echo. ColdFusion MX 7 Services started.
echo.
goto menu
 
:stopcf7
echo.
net stop "ColdFusion MX 7 Application Server"
net stop "ColdFusion MX 7 ODBC Agent"
net stop "ColdFusion MX 7 ODBC Server"
net stop "ColdFusion MX 7 Search Server"
cls
echo.
echo. ColdFusion MX 7 Services stopped.
echo.
goto menu
 
:quit

Related Blog Posts