2009/03/31

Change folder of Default SMTP

CURRENT CONFIGURATION: Microsoft Windows 2003 Server, IIS, SMTP Service, Message Queuing

OBJECTIVE: Change folder of Default SMTP

ISSUE: ISS Manager Console cannot configure all of IIS SMTP directories

SOLUTION:
We can use adsutil.vbs.
I wrote simple batch file for that

--- Start of IIS_SMTP_folder_relocate.cmd batch file ---

@echo on
:: *****************************************************
:: Author: Vadim Zenin http://vadimszenins.blogspot.com
:: Version: 1.00
:: Date: 25/03/2009 10:37
:: Change IIS SMTP directory location
::
:: Usage: %SCRIPTNAME%
::
:: Version 1.00 revision:
::
:: *****************************************************
::@echo off

@SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

FOR %%I IN ( "%0" ) DO SET SCRIPTNAME=%%~nxI
SET TOOLS=C:\tools
SET LOGDIR=%TOOLS%\logs
SET LOGFILE=%LOGDIR%\%SCRIPTNAME%.log

SET DESTINATIONDISK=D:
SET DESTINATIONFOLDER=mailroot
SET DESTINATION=%DESTINATIONDISK%\%DESTINATIONFOLDER%

:: Require
SET ADSUTIL=%SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs
:: ==============================================================

if not exist %LOGDIR% md %LOGDIR%
echo ====================== >> %LOGFILE%
echo %DATE% %TIME% %SCRIPTNAME% is started >> %LOGFILE%

SC stop smtpsvc >> %LOGFILE%

:: Check requirements
if not exist %ADSUTIL% ( echo %ADSUTIL% is required >>%LOGFILE%
exit 128)

if not exist %DESTINATION% md %DESTINATION% >>%LOGFILE%
if not exist %DESTINATION%\Badmail md %DESTINATION%\Badmail >>%LOGFILE%
if not exist %DESTINATION%\Drop md %DESTINATION%\Drop >>%LOGFILE%
if not exist %DESTINATION%\Pickup md %DESTINATION%\Pickup >>%LOGFILE%
if not exist %DESTINATION%\Queue md %DESTINATION%\Queue >>%LOGFILE%

:: Relocate IIS SMTP folders
cscript %ADSUTIL% SET /SmtpSvc/1/BadMailDirectory %DESTINATION%\Badmail >> %LOGFILE%
cscript %ADSUTIL% SET /SmtpSvc/1/DropDirectory %DESTINATION%\Drop >> %LOGFILE%
cscript %ADSUTIL% SET /SmtpSvc/1/PickupDirectory %DESTINATION%\Pickup >> %LOGFILE%
cscript %ADSUTIL% SET /SmtpSvc/1/QueueDirectory %DESTINATION%\Queue >> %LOGFILE%

SC start smtpsvc >> %LOGFILE%

:END
::SET RETURN=0
echo %DATE% %TIME% %SCRIPTNAME% is finished>> %LOGFILE%
@notepad %LOGFILE%
echo. >> %LOGFILE%
exit /B %RETURN%


--- The End of IIS_SMTP_folder_relocate.cmd batch file ---

All IIS SMTP service settings we can check in file %SYSTEMROOT%\system32\inetsrv\MetaBase.xml

DOWNLOAD:
Download IIS_SMTP_folder_relocate.zip md5: 10ed6dc64d6f8822a4031b94b43b622e

Комментариев нет: