http://m.blog.csdn.net/article/details?id=3647566
DelFilter("phpsirfilter") Function DelFilter ( ByVal strFilterName) Dim objFilterProps, objFilters Dim strLoadOrder Dim intStartFilt Err.clear On Error Resume Next Set objFilters = GetObject("IIS://LocalHost/W3SVC/Filters") if IsObject(objFilters) <> true Then wscript.echo "GetObject Filters" AddFilter =false End If strLoadOrder = objFilters.FilterLoadOrder wscript.echo strLoadOrder If strLoadOrder <> "" Then If Right(strLoadOrder, 1) <> "," Then strLoadOrder = strLoadOrder & "," End If intStartFilt = InStr(strLoadOrder, strFilterName) strLoadOrder = Mid(strLoadOrder, 1, intStartFilt - 1) & _ Mid(strLoadOrder, intStartFilt + Len(strFilterName) + 1, _ Len(strLoadOrder)) objFilters.FilterLoadOrder= strLoadOrder objFilters.SetInfo objFilters.Delete "IIsFilter", strFilterName wscript.echo "del filter end" objFilters.SetInfo End If wscript.echo strLoadOrder wscript.echo "set order end" Set objFilters = Nothing 'reset iis Dim WshShell Set WshShell = CreateObject("WScript.Shell") WshShell.Run "iisreset /noforce" , 0, True wscript.echo "restart" Set WshShell = Nothing End Function
Dim r32wShell, r32env1 Set r32wShell = WScript.CreateObject("WScript.Shell") '判断环境是否是32抑或64位 r32env1 = r32wShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%") '取当前路径 curpath = createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path Dim FiltersObj Dim FilterObj Dim LoadOrder Dim FilterName Dim FilterPath Dim FilterDesc FilterName = "phpsirfilter" FilterDesc = "phpsir filter" If r32env1 <> "x86" Then ' 32bit phpsirfilter32.dll FilterPath = curpath + "\phpsirfilter32.dll" Else ' 64bit phpsirfilter64.dll FilterPath = curpath + "\phpsirfilter64.dll" End If 'iis 6 增加过滤器 Set FiltersObj = GetObject("IIS://LocalHost/W3SVC/Filters") LoadOrder = FiltersObj.FilterLoadOrder If LoadOrder <> "" Then LoadOrder = LoadOrder & "," End If LoadOrder = LoadOrder & FilterName FiltersObj.FilterLoadOrder = LoadOrder FiltersObj.SetInfo Set FilterObj = FiltersObj.Create("IIsFilter", FilterName) FilterObj.FilterPath = FilterPath FilterObj.FilterDescription = FilterDesc FilterObj.SetInfo