@echo off
REM THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
REM ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
REM THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
REM PARTICULAR PURPOSE.

REM Copyright (C) 2004 Microsoft Corporation.  All Rights Reserved.

REM ************************************************************************
REM ************************************************************************
REM runadlb.cmd <ServerName> <SiteName> <logdirectory>
REM 
REM Runs adlb using the recommended command line.
REM 
REM ************************************************************************
REM ************************************************************************

REM Takes a system backup of the machine.
setlocal

IF "%1" == "" goto :ERRUSAGE
IF "%2" == "" goto :ERRUSAGE
IF "%3" == "" goto :ERRUSAGE
IF "%1" == "/?" goto :USAGE

set SERVERNAME=%1
set SITENAME=%2
set LOGDIRECTORY=%3


REM Determine the log date.
call :GETFILEDATE

REM Run adlb and pipe the output to a log.

adlb /server:%SERVERNAME% /site:%SITENAME% /c /log:%LOGDIRECTORY%\adlb.%FILEDATE%.log /cacheinput:%LOGDIRECTORY%\adlb.cache.%FILEDATE%.log /v /perf /stats

endlocal
goto :EOF

REM ************************* GETFILEDATE **********************************
REM ************************************************************************

:GETFILEDATE

REM Generate a date that can be used in a file name.
set FILEDATE=%DATE:~4,2%_%DATE:~7,2%_%DATE:~12,2%
goto :EOF

:ERRUSAGE
call :USAGE
exit /b 1
goto :EOF

:USAGE
echo runadlb.cmd ^<ServerName^> ^<SiteName^> ^<LogDirectory^>
echo Runs ADLB per the Windows Server 2003 Active Directory
echo Branch Office Deployment Guide recommendations.
echo.
echo ServerName   - the name of the server on which to make connection object
echo                configuration changes.
echo.
echo SiteName     - the name of the site on which to make connection object
echo                configuration changes.
echo.
echo LogDirectory - the directory which to store ADLB's output logs.
echo                runadlb.cmd sets the file names to be of the form:
echo                  adlb.%%FILEDATE%%.log
echo                  adlb.%%FILEDATE%%.cache.log
echo                %%FILEDATE%% is a representation of the current date.
echo. 
goto :EOF 