iis6 根据过滤器名字删除过滤器的vbs

delfiltervbs

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

发表评论

邮箱地址不会被公开。 必填项已用*标注