@setlocal
@if "%1"=="" goto usage
@if "%1"=="/?" goto usage
@if "%1"=="-?" goto usage
@rem Parameter is either a drive letter, or "none"
@rem check for presence of adsutil.vbs
@set adu=%systemdrive%\inetpub\adminscripts\adsutil.vbs
@if exist %adu% goto stopsrv
@echo This tool requires %adu% from the IIS scripts.
@goto fail
:stopsrv
@rem Record what Exchange services are currently running
@echo off
@set StartSA=0
@set StartIS=0
@set StartMTA=0
@set StartWWW=0
For /f "delims=" %%a in ('net start') do if "%%a" == " Microsoft Exchange System Attendant" set StartSA=1
For /f "delims=" %%a in ('net start') do if "%%a" == " Microsoft Exchange Information Store" set StartIS=1
For /f "delims=" %%a in ('net start') do if "%%a" == " Microsoft Exchange MTA Stacks" set StartMTA=1
For /f "delims=" %%a in ('net start') do if "%%a" == " World Wide Web Publishing Service" set StartWWW=1
@echo on
@echo Stopping Exchange services...
net stop msexchangesa /y
@echo Stopping Web services...
net stop w3svc /y
@if "%temp%" == "" set temp="C:\"
@set regfile=%temp%\addm.reg
@echo REGEDIT4 > "%regfile%"
@if "%1"=="none" goto deldrive
@set drive=%1
@set newdrive=%drive:~0,1%
@echo Adding %newdrive% drive mapping to the registry...
@echo [HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EXIFS\Parameters] >> "%regfile%"
@echo "DriveLetter"="%newdrive%" >> "%regfile%"
@goto doregedit
:deldrive
@echo removing existing drive letter mapping...
For /f "delims=\=>; tokens=1,2*" %%a in ('subst') do (
if /i "%%c" == " BackOfficeStorage" (
subst %%a /d
)
)
@echo Removing drive mapping from the registry...
@echo [HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EXIFS\Parameters] >> "%regfile%"
@echo "DriveLetter"="" >> "%regfile%"
:doregedit
@type %regfile%
regedit -s "%regfile%"
@if errorlevel 0 goto mb
@goto fail
:mb
@echo Touching the metabase to force update of Exchange virtual roots...
cscript %adu% delete /ds2mb/HighWaterMarks
@goto restart
:restart
@echo Restarting services...
@if %StartSA%==1 net start "Microsoft Exchange System Attendant" /y
@if %StartIS%==1 net start "Microsoft Exchange Information Store" /y
@if %StartMTA%==1 net start "Microsoft Exchange MTA Stacks" /y
@if %StartWWW%==1 net start w3svc /y
@goto done
:fail
@echo The operation did not suclearcase/" target="_blank" >cceed.
@goto end
:done
@echo Done.
@goto end
:usage
@echo Usage: ifsdrive ^<drive-letter^>
@echo ifsdrive none
@echo Modifies or removes the mapping of Exchange storage to a local drive letter.
@echo Specify a single letter to map Exchange storage to that drive.
@echo Specify "none" (without quotes) to remove the mapping.
@goto end
:end
@if not "%regfile%" == "" del "%regfile%"
ifsdrive none
备注: 为删除该映射,请使用完整的“none”一词。ifsdrive 驱动器盘符
驱动器盘符 默认情况下是驱动器 M,但如果 IFS 驱动器映射曾被改为另一个驱动器盘符,那么请改用新的驱动器盘符。