@echo off
set Today=%date:~0,4%%date:~5,2%%date:~8,2% %time:~0,5%
c:\windows\system32\inetsrv\AppCmd.exe list apppool|find "state:Stopped" >D:\temp\iis\erro.txt
for /f "tokens=1-2" %%a in (D:\temp\iis\erro.txt) do ( echo %%b >>D:\temp\iis\name.txt )
del D:\temp\iis\erro.txt
for /f "tokens=*" %%i in ('type "D:\temp\iis\name.txt"') do (
echo %Today% %%i it's down >>D:\temp\iis\iis.log
c:\windows\system32\inetsrv\AppCmd.exe start apppool /apppool.name:%%i
)
del D:\temp\iis\name.txt
这个主要是通过检测应用池的的状态,如果是停止,就进行启动。然后加到计划任务中。