on Windows 2003。
不論加密與否都不影響還原

restore.bat
@echo off

@rem =========================================
@rem Author: flyfox 20121102
@rem 使用需知
@rem 1. 需安裝 IIS 6
@rem 2. 需安裝 7-zip
@rem 3. 需將要還原的設定檔解壓縮至 D:\Backup\
@rem =========================================

@rem =========================================
@rem 設定各路徑變數
@rem =========================================
@set DDir=D:\Backup\
@set zip="C:\Program Files\7-Zip\7z.exe"
@set batlog=D:\bat\log

@rem =========================================
@rem 設定備份檔名稱、log檔名稱
@rem =========================================
@set file=%computername%-iisbackup.xml
@set log=D:\bat\log\log-%date:~0,4%%date:~5,2%%date:~8,2%-%time:~0,2%%time:~3,2%%time:~6,2%.txt
@set log=%log: =0%

@rem =========================================
@rem 還原 IIS 設定檔
@rem =========================================
@echo ================ start ================== > %log%
@echo Date: %date% Time: %time% >> %log%
@if exist %DDir%%file% (iiscnfg /import /f %DDir%%file% /sp /LM/W3SVC /dp /LM/W3SVC /children /inherited && echo. >> %log%) else (goto noxml)
@echo Restore Success! >> %log%
@goto close

:noxml
@rem =========================================
@rem 找不到 IIS 備份檔
@rem =========================================
@echo can not find IIS config file! >> %log%
@forfiles /P noxml /S /M *.* /D -30 /C "cmd /c del @path"
@exit
@echo on

:close
@exit
@echo on

flyfox 發表在 痞客邦 PIXNET 留言(0) 人氣()