Okay, this is a little bit of an overkill for some folks but here is
my restart batch file for Imail.  I keep a shortcut to this on
my desktop for emergencies.  In the event that I am not
at the server I can also set this as an AT command to run
in the middle of the night.  (AT 01:00 "c:\batch\imrst.bat")

A couple of notes:
This requires the KILL.EXE from the Resource Kit.  If you
want the server to reboot in the event of serious errors, it
also requires SHUTDOWN.EXE from the Resource Kit.

Use this at your own risk please.  The batch file simply checks
for the existence of running services then shuts down any running
services and restarts them.  If the service is not running before the
batch is run, it will not be running when the batch is through.

If this message wraps and ruins the layout of the batch you can
download the file and example of the restart.log which is produced
at ftp://ftp.netease.net/pub/addon/restart.zip

Here ya go....

[BEGIN IMRST.BAT]
echo off
rem This will maintain 5 copies of the restart log

d:
cd\imail
if exist restart.5 del restart.5
if exist restart.4 ren restart.4 restart.5
if exist restart.3 ren restart.3 restart.4
if exist restart.2 ren restart.2 restart.3
if exist restart.1 ren restart.1 restart.2
if exist restart.log ren restart.log restart.1
echo Housecleaning done

echo -------------------->>d:\imail\restart.log
echo Start Imail Restart Date/Time:>>d:\imail\restart.log
echo. | date | find /i "current">>d:\imail\restart.log
echo. | time | find /i "current">>d:\imail\restart.log
echo.>>d:\imail\restart.log
echo Stopping Imail Services...
echo.

set IMFIN=0
set IMMAP=0
set IMLDAP=0
set IMMON=0
set IMPOP=0
set IMPWD=0
set IMSMTP=0
set IMSYS=0
set IMWEB=0
set IMWHO=0
set IMAILERR=0

:BEGIN
:FINGER
net start | find /i "IMail FINGER Server">NUL
if errorlevel==1 goto IMAP
set IMFIN=1

:IMAP
net start | find /i "IMail IMAP4 Server">NUL
if errorlevel==1 goto LDAP
set IMMAP=1

:LDAP
net start | find /i "IMail LDAP Server">NUL
if errorlevel==1 goto MONITOR
set IMLDAP=1

:MONITOR
net start | find /i "IMail Monitor Service">NUL
if errorlevel==1 goto POP
set IMMON=1

:POP
net start | find /i "IMail POP3 Server">NUL
if errorlevel==1 goto PWD
set IMPOP=1

:PWD
net start | find /i "IMail PWD Server">NUL
if errorlevel==1 goto SMTP
set IMPWD=1

:SMTP
net start | find /i "IMail SMTP Server">NUL
if errorlevel==1 goto SYSLOG
set IMSMTP=1

:SYSLOG
net start | find /i "IMail Sys Logger Service">NUL
if errorlevel==1 goto WEB
set IMSYS=1

:WEB
net start | find /i "IMail Web Service">NUL
if errorlevel==1 goto WHOIS
set IMWEB=1

:WHOIS
net start | find /i "IMail WHOIS Server">NUL
if errorlevel==1 goto STOPIMAIL
set IMWHO=1

:STOPIMAIL
if %IMFIN%==0 goto NOFIN
net stop "IMail FINGER Server" /y>>d:\imail\restart.log
if errorlevel==1 goto STOPERROR

:NOFIN
if %IMMAP%==0 goto NOIMAP
net stop "IMail IMAP4 Server" /y>>d:\imail\restart.log
if errorlevel==1 goto STOPERROR

:NOIMAP
if %IMLDAP%==0 goto NOLDAP
net stop "IMail LDAP Server" /y>>d:\imail\restart.log
if errorlevel==1 goto STOPERROR

:NOLDAP
if %IMMON%==0 goto NOMON
net stop "IMail Monitor Service" /y>>d:\imail\restart.log
if errorlevel==1 goto STOPERROR

:NOMON
if %IMPOP%==0 goto NOPOP
net stop "IMail POP3 Server" /y>>d:\imail\restart.log
if errorlevel==1 goto STOPERROR

:NOPOP
if %IMPWD%==0 goto NOPWD
net stop "IMail PWD Server" /y>>d:\imail\restart.log
if errorlevel==1 goto STOPERROR

:NOPWD
if %IMSMTP%==0 goto NOSMTP
net stop "IMail SMTP Server" /y>>d:\imail\restart.log
if errorlevel==1 goto STOPERROR

:NOSMTP
if %IMSYS%==0 goto NOSYS
net stop "IMail Sys Logger Service" /y>>d:\imail\restart.log
if errorlevel==1 goto STOPERROR

:NOSYS
if %IMWEB%==0 goto NOWEB
net stop "IMail Web Service" /y>>d:\imail\restart.log
if errorlevel==1 goto STOPERROR

:NOWEB
if %IMWHO%==0 goto NOWHO
net stop "IMail WHOIS Server" /y>>d:\imail\restart.log
if errorlevel==1 goto STOPERROR

goto STOPPED

:STOPERROR
KILL.EXE FINGRD32.exe
if errorlevel==1 goto KILLIT
KILL.EXE IMAP4D32.exe
if errorlevel==1 goto KILLIT
KILL.EXE ILDAP.exe
if errorlevel==1 goto KILLIT
KILL.EXE IMonitor.exe
if errorlevel==1 goto KILLIT
KILL.EXE POP3D32.exe
if errorlevel==1 goto KILLIT
KILL.EXE PSERVE.exe
if errorlevel==1 goto KILLIT
KILL.EXE SMTPD32.exe
if errorlevel==1 goto KILLIT
KILL.EXE SYSLOGD.exe
if errorlevel==1 goto KILLIT
KILL.EXE IWebMsg.exe
if errorlevel==1 goto KILLIT
KILL.EXE WHOISD32.exe
if errorlevel==1 goto KILLIT
goto STOPPED

:KILLIT
set IMAILERR=1

:STOPPED

:STARTIMAIL
echo Start Imail Services Date/Time:>>d:\imail\restart.log
echo. | date | find /i "current">>d:\imail\restart.log
echo. | time | find /i "current">>d:\imail\restart.log
echo.>>d:\imail\restart.log
echo Starting Imail services...
echo.

if %IMFIN%==0 goto NOFINST
net start "IMail FINGER Server" /y>>d:\imail\restart.log
if errorlevel==1 goto STARTERROR

:NOFINST
if %IMMAP%==0 goto NOIMAPST
net start "IMail IMAP4 Server" /y>>d:\imail\restart.log
if errorlevel==1 goto STARTERROR

:NOIMAPST
if %IMLDAP%==0 goto NOLDAPST
net start "IMail LDAP Server" /y>>d:\imail\restart.log
if errorlevel==1 goto STOPERROR

:NOLDAPST
if %IMMON%==0 goto NOMONST
net start "IMail Monitor Service" /y>>d:\imail\restart.log
if errorlevel==1 goto STARTERROR

:NOMONST
if %IMPOP%==0 goto NOPOPST
net start "IMail POP3 Server" /y>>d:\imail\restart.log
if errorlevel==1 goto STARTERROR

:NOPOPST
if %IMPWD%==0 goto NOPWDST
net start "IMail PWD Server" /y>>d:\imail\restart.log
if errorlevel==1 goto STARTERROR

:NOPWDST
if %IMSMTP%==0 goto NOSMTPST
net start "IMail SMTP Server" /y>>d:\imail\restart.log
if errorlevel==1 goto STARTERROR

:NOSMTPST
if %IMSYS%==0 goto NOSYSST
net start "IMail Sys Logger Service" /y>>d:\imail\restart.log
if errorlevel==1 goto STARTERROR

:NOSYSST
if %IMWEB%==0 goto NOWEBST
net start "IMail Web Service" /y>>d:\imail\restart.log
if errorlevel==1 goto STARTERROR

:NOWEBST
if %IMWHO%==0 goto NOWHOST
net start "IMail WHOIS Server" /y>>d:\imail\restart.log
if errorlevel==1 goto STARTERROR

:NOWHOST
if %IMAILERR%==0 goto FINALSTEP

:STARTERROR
echo SERVICE RESTART ERROR...>>d:\imail\restart.log
echo One or more of the services could not be
restarted.>>d:\imail\restart.log
echo Please check the Event Viewer logs for more
information.>>d:\imail\restart.log
echo We are now going to reboot the server as a last
resort.>>d:\imail\restart.log
echo We are now going to reboot the server as a last resort
echo Press CTL+C then Start/Run type SHUTDOWN /A to abort within the next 30
seconds
SHUTDOWN.EXE /L /R /T:30 /Y

:FINALSTEP
set IMFIN=
set IMMAP=
set IMLDAP=
set IMMON=
set IMPOP=
set IMPWD=
set IMSMTP=
set IMSYS=
set IMWEB=
set IMWHO=
set IMAILERR=

:SUCCESS
echo Imail Restart Complete Date/Time:>>d:\imail\restart.log
echo. | date | find /i "current">>d:\imail\restart.log
echo. | time | find /i "current">>d:\imail\restart.log
echo.>>d:\imail\restart.log
echo Restart Complete...
echo.
echo -------------------->>d:\imail\restart.log
goto END

:END

:EXIT


[BEGIN Restart.log]
--------------------
Start Imail Restart Date/Time:
The current date is: Sat 06/05/1999
The current time is: 11:46:07.04

The IMail FINGER Server service is stopping.
The IMail FINGER Server service was stopped successfully.


The IMail IMAP4 Server service is stopping.
The IMail IMAP4 Server service was stopped successfully.


The IMail LDAP Server service is stopping.
The IMail LDAP Server service was stopped successfully.


The IMail Monitor Service service is stopping.
The IMail Monitor Service service was stopped successfully.


The IMail POP3 Server service is stopping.
The IMail POP3 Server service was stopped successfully.


The IMail PWD Server service is stopping.
The IMail PWD Server service was stopped successfully.


The IMail SMTP Server service is stopping.
The IMail SMTP Server service was stopped successfully.


The IMail Sys Logger Service service is stopping.
The IMail Sys Logger Service service was stopped successfully.


The IMail Web Service service is stopping.
The IMail Web Service service was stopped successfully.


The IMail WHOIS Server service is stopping.
The IMail WHOIS Server service was stopped successfully.


Start Imail Services Date/Time:
The current date is: Sat 06/05/1999
The current time is: 11:46:40.54

The IMail FINGER Server service is starting.
The IMail FINGER Server service was started successfully.


The IMail IMAP4 Server service is starting.
The IMail IMAP4 Server service was started successfully.


The IMail LDAP Server service is starting.
The IMail LDAP Server service was started successfully.


The IMail Monitor Service service is starting.
The IMail Monitor Service service was started successfully.


The IMail POP3 Server service is starting.
The IMail POP3 Server service was started successfully.


The IMail PWD Server service is starting.
The IMail PWD Server service was started successfully.


The IMail SMTP Server service is starting.
The IMail SMTP Server service was started successfully.


The IMail Sys Logger Service service is starting.
The IMail Sys Logger Service service was started successfully.


The IMail Web Service service is starting.
The IMail Web Service service was started successfully.


The IMail WHOIS Server service is starting.
The IMail WHOIS Server service was started successfully.


Imail Restart Complete Date/Time:
The current date is: Sat 06/05/1999
The current time is: 11:47:02.64

--------------------

Reply via email to