Pete Freitag Pete Freitag

Batch Files to Restart Services on Windows

Published on October 09, 2002
By Pete Freitag
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)


windows services bat batch iis coldfusion

Batch Files to Restart Services on Windows was first published on October 09, 2002.

If you like reading about windows, services, bat, batch, iis, or coldfusion then you might also like:

Fixinator

The Fixinator Code Security Scanner for ColdFusion & CFML is an easy to use security tool that every CF developer can use. It can also easily integrate into CI for automatic scanning on every commit.


Try Fixinator

CFBreak
The weekly newsletter for the CFML Community


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
by joe on 04/12/2010 at 10:54:44 PM UTC
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
by joe on 09/16/2011 at 2:34:52 PM UTC