Batch Files to Restart Services on Windows

October 09, 2002
coldfusion

I wrote some batch files today for restarting services on windows. The bat files can be used to restart ColdFusion MX or IIS services on Windows NT/2000/XP.

Batch File to restart ColdFusion MX

@echo off
REM - File: cfmxrestart.bat
REM - Description: Restart's ColdFusion MX Services
REM - Author: Pete Freitag
echo Restarting ColdFusion MX...
echo ======================================================
net stop "ColdFusion MX Application Server"
net stop "ColdFusion MX ODBC Agent"
net stop "ColdFusion MX ODBC Server"
net start "ColdFusion MX Application Server"
net start "ColdFusion MX ODBC Agent"
net start "ColdFusion MX ODBC Server"
echo ======================================================
echo ColdFusion MX Restarted

Batch file to restart IIS

@echo off
REM - File: iisrestart.bat
REM - Description: Restart's IIS (Web, FTP, SMTP)
REM - Author: Pete Freitag
REM - ADD REM comments if you don't want to restart any
REM - of Services
echo Restarting IIS...
echo ======================================================
net stop "World Wide Web Publishing Service"
net start "World Wide Web Publishing Service"
net stop "FTP Publishing Service"
net start "FTP Publishing Service"
net stop "Simple Mail Transport Protocol (SMTP)"
net start "Simple Mail Transport Protocol (SMTP)"
echo ======================================================
echo IIS Restarted
Bat files are handy because you can restart multiple services with one command. You can either double click the bat file to run it, schedule it, or throw it in c:\windows\system32 and then run it from anywhere in the command prompt or (Start->Run)

Like this? Follow me ↯


You might also like:

13 people found this page useful, what do you think?

Comments

i like it, worked like a charm.
i actually used cfexecute to run it
but if you have cf hanging you might want to have a php script execute it, or some other language
Antoine -

You really just need to substitute in the service name from Services, for instance "ColdFusion 9 Application Server"

For CF8 I use this:

@echo off
echo Restarting ColdFusion 8...
echo ======================================================
net stop "ColdFusion 8 Application Server"
choice /T 20 /D y
net start "ColdFusion 8 Application Server"
echo ======================================================
echo ColdFusion 8 Restarted


Foundeo Inc.