Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
2.9 KiB

  1. '''''''''''''''''''''''''''''''''''''''''''''
  2. '
  3. ' Filter Registration Utility
  4. '
  5. '''''''''''''''''''''''''''''''''''''''''''''
  6. ' Description:
  7. ' ------------
  8. ' This sample admin script allows you to install a new ISAPI filter on the server or
  9. ' the service.
  10. '
  11. ' To Run:
  12. ' -------
  13. ' This is the format for this script:
  14. '
  15. ' cscript regfilt.vbs <filterpath> [-n <filtername>]
  16. '
  17. ' NOTE: If you want to execute this script directly from Windows, use
  18. ' 'wscript' instead of 'cscript'.
  19. '
  20. '''''''''''''''''''''''''''''''''''''''''''''
  21. Option Explicit
  22. ' Initialize error checking
  23. On Error Resume Next
  24. ' Initialize variables
  25. Dim ArgCount, FName, FPath, FiltersObj, FilterObj, FullPath, LoadOrder
  26. ' Default values
  27. ArgCount = 0
  28. FName = "" ' Name of filter
  29. FPath = "" ' Path to filter DLL
  30. ' ** Parse Command Line
  31. ' Loop through arguments
  32. While ArgCount < Wscript.Arguments.Count
  33. ' Determine switches used
  34. Select Case Wscript.Arguments(ArgCount)
  35. Case "-n": ' Name of filter
  36. ' Move to next arg, which should be parameter
  37. ArgCount = ArgCount + 1
  38. If ArgCount => Wscript.Arguments.Count Then
  39. Call UsageMsg
  40. Else
  41. FName = Wscript.Arguments(ArgCount)
  42. End If
  43. Case "-h", "-?", "/?": ' Help!
  44. Call UsageMsg
  45. Case Else:
  46. If FPath <> "" Then ' Only one name allowed
  47. Call UsageMsg
  48. Else
  49. FPath = Wscript.Arguments(ArgCount)
  50. End If
  51. End Select
  52. ' Move pointer to next argument
  53. ArgCount = ArgCount + 1
  54. Wend
  55. ' Path to DLL filter must be provided
  56. If FPath = "" Then UsageMsg
  57. ' Set filter name to path, if none provided
  58. If FName = "" Then FName = FPath
  59. ' Access ADSI object for the IIsFilters object
  60. ' NOTE: If you wish to add a filter at the server level, you will have to check
  61. ' the IIsServer object for an IIsFilters node. If such a node does not exist, it will
  62. ' need to be created using Create().
  63. Set FiltersObj = GetObject("IIS://Localhost/W3SVC/Filters")
  64. ' Create and configure new IIsFilter object
  65. Set FilterObj = FiltersObj.Create("IIsFilter", FName)
  66. FilterObj.FilterPath = FPath
  67. ' Write info back to Metabase
  68. FilterObj.SetInfo
  69. ' Modify FilterLoadOrder, to include to new filter
  70. LoadOrder = FiltersObj.FilterLoadOrder
  71. If LoadOrder <> "" Then LoadOrder = LoadOrder & ","
  72. ' Add new filter to end of load order list
  73. LoadOrder = LoadOrder & FName
  74. FiltersObj.FilterLoadOrder = LoadOrder
  75. ' Write changes back to Metabase
  76. FiltersObj.SetInfo
  77. Wscript.Echo "Filter '" & FName & "' (path " & FPath & ") has been successfully registered."
  78. Wscript.Quit(0)
  79. ' Displays usage message, then QUITS
  80. Sub UsageMsg
  81. Wscript.Echo "Usage: cscript regfilt.vbs <filterpath> [-n <filtername>] "
  82. Wscript.Quit
  83. End Sub