ABServer.exe –syncnow Script

I recently worked with a customer that has a rather large OCS deployment.  Five Edge servers, two Director servers and Seven Front End servers.  They mainly leverage OCS for its IM/Presence and Live Meeting features.  All users are remote so all logins are via the Edge servers.  There was a need to manually run the “ABServer.exe –syncnow” on the particular server that has the ABService service running.  Since they have seven Front Ends, a solution was found programmatically of determining what server was actually running the ABService and then running the “ABServer.exe –syncnow” switch at a predetermined time via task scheduler.

#Searches tasklist for "IMAGENAME eq abserver.exe" (ABServer service)
#If ABService is NOT found to be running, script ends
#If ABService is found to be running, script continues and executes: abserver.exe -syncnow

@echo off
tasklist /FI "IMAGENAME eq abserver.exe" /FO CSV > search.log

FINDSTR ABServer.exe search.log > found.log

FOR /F %%A IN (found.log) DO IF %%~zA EQU 0 GOTO end

exit

:end

@echo Running ABServer.exe -syncnow

cd "C:\Program Files\Microsoft Office Communications Server 2007 R2\Server\Core"

abserver.exe -syncnow

del search.log
del found.log

Technorati Tags: Office Communications Server 2007 R2,OCS,address book,abserver.exe