然后用vbs脚本及批处理文件,结合任务计划程序,保证在每周六深夜1点执行IIS回收。
Recyclepool.vbs 文件内容:
-------------------------------------------------------------------------------------------------------------
appPoolName = WScript.Arguments(0)
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
Set oAppPool = oWebAdmin.Get("ApplicationPool.Name='" + appPoolName + "'")
oAppPool.Recycle
set fso=createobject("scripting.filesystemobject")
if (fso.fileexists("d:\appPool\recycleIISPool.log")) then
'1-forreading,2-forwriting,8-appending
set file=fso.opentextfile("d:\appPool\recycleIISPool.log",8,ture)
else
set file=fso.createtextfile( "d:\appPool\recycleIISPool.log",8,ture)
end if
'write(x)写入x个字符,writeline写入换行,writeblanklines(n)写入N个空行
file.writeline now&" 应用程序池“"&appPoolName &"”已经回收成功。"
file.close
-----------------------------------------------------------------------------------------------------------
接下来就设定windows 任务计划就可以了。