Using a Batch File to Install SMBAGENT

The following batch file consists of calls to the Microsoft Exchange Server sample applications listed above. The batch file uses the same sample applications as the keyboard commands. You can use the batch file to install your mailbox agent.

    To install a new service using a batch file

Prepare a file similar to the following and execute it on your server computer.

@echo off
rem test smba inst utilities from exchsdk 
rem =====================================================================

rem check for Help request
if .%1.==.-?. goto usage

rem check if deleting
set deletemode=   
if .%1.==.. goto start
if .%1.==.delete. goto delete
if .%1.==.DELETE. goto delete
rem shouldn't fall through to here, show usage
goto usage

:delete
rem wants to delete
set deletemode=/delete

:start
echo checking for Organization and Site environment variables...
if .%Organization%.==.. goto usage
if .%Site%.==.. goto usage
if .%projroot%.==.. set projroot=c:\exchsdk
echo Organization is %Organization%
echo Site is %Site%
echo Projroot is %projroot%
echo delete status is %deletemode%
echo.

echo setting temporary variable for password
set userpassword=slapshot

echo moving to %projroot%\bin subdirectory
c:
cd %projroot%\bin

echo.
echo installing mailbox agent...
%projroot%\bin\mbinst /SITEDN=/o=%Organization%/ou=%Site% 
/DISPLAY_NAME=SampleMBA /RELATIVE_DN=/cn=Recipients/cn=SampleMBA 
/SERVER=%COMPUTERNAME% /EXTNAME=SampleMBA 
 %deletemode%

echo.
echo installing service (mailbox agent)...
%projroot%\bin\servinst /SITEDN=/o=%Organization%/ou=%Site% 
/OBJNAME=/cn=Recipients/cn=SampleMBA /OBJTYPE=agent 
/SERVICE=SampleMBA /DISPLAY_NAME=SampleMBA /DEPENDENCIES= 
/EXE=%projroot%\bin\smbagent.exe /SERVER=%COMPUTERNAME% 
/ACCOUNT=%USERDOMAIN%\%USERNAME% /PASSWORD=%userpassword% 
%deletemode%

echo.
echo installing extension (configuration) data (mailbox agent)...
%projroot%\bin\extninst /SITEDN=/o=%Organization%/ou=%Site% 
/DISPLAY_NAME=SampleMBA /MACHINE=i386 /NAME=SampleMBA 
/EXTDLL=%projroot%\bin\smbadmin.dll /SERVER=%COMPUTERNAME% 
%deletemode%

if .%1.==.delete. goto continue
cd\exchsrvr\add-ins
md SampleMBA
cd SampleMBA
md i386
cd i386
xcopy %projroot%\bin\smbadmin.dll .

:continue
cd %projroot%\bin


echo ----------------------------------------------

goto done

:usage
echo Installing the Sample Mailbox Agent
echo example: mbtest  [(delete)]
echo add delete if removing the smba
echo Mailbox agent will be named SampleMBA
echo.
echo Environment: these environment variables must be set to their 
proper values
echo Organization=Microsoft
echo Site=Site6 
echo projroot=[root directory for SDK] NOTE: this one is set when you 
install SDK
echo.
echo Assumptions:
echo server name is same as computer name: %computername%
echo addrtype is EDK
echo user domain and name are %userdomain% and %username%

:done
set userpassword=
set deletemode=
echo All done.