en · de

SnTT: Starting Batch Files with Program Documents-Update

by Thomas,
assono GmbH, Standort Kiel,

showntell-w120.png A small update for my blog entry SnTT: Starting Batch Files with Program Documents from 2007:

A friendly reader of our blog (Thanks, Ruaridh) brought my attention to the fact that the sample script didn't run through: It quits the server, but doesn't start it again, when started by a program document. Running it manually, everything works as expected.

After a long debugging session, I found the root cause: When a batch script tries to rename or delete a non-existant file, it prints a warning in the console, but continues, when it was started manually. If started by a program document, it simply quits.

The solution is to check, if the file exists, before trying to rename or delete it. Thus instead of writing:
DEL "%DOMINO_DATA%\log.nsf.4" >>"%BATCH_FILE_LOG%"
REN "%DOMINO_DATA%\log.nsf.3" "%DOMINO_DATA%\log.nsf.4" >>"%BATCH_FILE_LOG%"
better use:
IF EXIST "%DOMINO_DATA%\log.nsf.4" DEL "%DOMINO_DATA%\log.nsf.4" >>"%BATCH_FILE_LOG%"
IF EXIST "%DOMINO_DATA%\log.nsf.3" REN "%DOMINO_DATA%\log.nsf.3" "log.nsf.4" >>"%BATCH_FILE_LOG%"

The corrected batch script::

@ECHO OFF
REM variable parts; to be adapted for each installation
SET DOMINO_SERVICE=Lotus Domino Server (notesdomino6)
SET DOMINO_PROGS=C:\Programme\Domino6
SET DOMINO_DATA=D:\Notes\Domino6
SET BATCH_FILE_LOG=%DOMINO_DATA%\weekly-maintenance.log

REM log settings
ECHO Weekly maintenance started >>"%BATCH_FILE_LOG%"
date /t >>"%BATCH_FILE_LOG%"
time /t >>"%BATCH_FILE_LOG%"
ECHO DOMINO_SERVICE: %DOMINO_SERVICE% >>"%BATCH_FILE_LOG%"
ECHO DOMINO_PROGS: %DOMINO_PROGS% >>"%BATCH_FILE_LOG%"
ECHO DOMINO_DATA: %DOMINO_DATA% >>"%BATCH_FILE_LOG%"
ECHO. >>"%BATCH_FILE_LOG%"

ECHO Stopping Domino service >>"%BATCH_FILE_LOG%"
net stop "%DOMINO_SERVICE%" >>"%BATCH_FILE_LOG%"

ECHO Compacting system databases >>"%BATCH_FILE_LOG%"
"%DOMINO_PROGS%\ncompact" -c -i names.nsf >>"%BATCH_FILE_LOG%"
"%DOMINO_PROGS%\ncompact" -c -i admin4.nsf >>"%BATCH_FILE_LOG%"
"%DOMINO_PROGS%\ncompact" -c -i events4.nsf >>"%BATCH_FILE_LOG%"
REM Domino 7+ only
REM "%DOMINO_PROGS%\ncompact" -c -i ddm.nsf >>"%BATCH_FILE_LOG%"

ECHO Refreshing view in Domino Directory >>"%BATCH_FILE_LOG%"
"%DOMINO_PROGS%\nupdall" -R names.nsf >>"%BATCH_FILE_LOG%"

ECHO Save log database (4 generations) >>"%BATCH_FILE_LOG%"
IF EXIST "%DOMINO_DATA%\log.nsf.4" DEL "%DOMINO_DATA%\log.nsf.4" >>"%BATCH_FILE_LOG%"
IF EXIST "%DOMINO_DATA%\log.nsf.3" REN "%DOMINO_DATA%\log.nsf.3" "log.nsf.4" >>"%BATCH_FILE_LOG%"
IF EXIST "%DOMINO_DATA%\log.nsf.2" REN "%DOMINO_DATA%\log.nsf.2" "log.nsf.3" >>"%BATCH_FILE_LOG%"
IF EXIST "%DOMINO_DATA%\log.nsf.1" REN "%DOMINO_DATA%\log.nsf.1" "log.nsf.2" >>"%BATCH_FILE_LOG%"
IF EXIST "%DOMINO_DATA%\log.nsf" REN "%DOMINO_DATA%\log.nsf" "log.nsf.1" >>"%BATCH_FILE_LOG%"

ECHO Restarting Domino service >>"%BATCH_FILE_LOG%"
net start "%DOMINO_SERVICE%" >>"%BATCH_FILE_LOG%"
ECHO. >>"%BATCH_FILE_LOG%"

ECHO Weekly maintenance completed >>"%BATCH_FILE_LOG%"
date /t >>"%BATCH_FILE_LOG%"
time /t >>"%BATCH_FILE_LOG%"
ECHO. >>"%BATCH_FILE_LOG%"

Technical article IBM Domino Administration

You have questions about this article? Contact us: blog@assono.de

Sie wollen eine individuelle Beratung oder einen Workshop? Read more

More interesting entries

Any questions? Contact us.

If you want to know more about our offers, you can contact us at any time. There are several ways to contact us for a non-binding first consultation.

assono GmbH

Location Kiel (headquarters)
assono GmbH
Lise-Meitner-Straße 1–7
24223 Schwentinental

Location Hamburg
assono GmbH
Bornkampsweg 58
22761 Hamburg

Phone numbers:
Human resources department: +49 4307 900 407
Marketing department: +49 4307 900 411

E-Mail adresses:
contact@assono.de
bewerbung@assono.de