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.

127 lines
3.3 KiB

  1. '''''''''''''''''''''''''''''''''''''''''''''
  2. '
  3. ' Logging Module Enumeration Utility
  4. '
  5. '''''''''''''''''''''''''''''''''''''''''''''
  6. ' Description:
  7. ' ------------
  8. ' This sample admin script allows you configure logging services for IIS.
  9. '
  10. ' To Run:
  11. ' -------
  12. ' This is the format for this script:
  13. '
  14. ' cscript logenum.vbs [<adspath>]
  15. '
  16. ' NOTE: If you want to execute this script directly from Windows, use
  17. ' 'wscript' instead of 'cscript'.
  18. '
  19. '''''''''''''''''''''''''''''''''''''''''''''
  20. ' Initialize error checking
  21. On Error Resume Next
  22. ' Initialize variables
  23. Dim ArgCount, TargetNode, SObj, ModListObj, ChildObj, RealModObj, LogNameStr
  24. ' Default values
  25. ArgCount = 0
  26. TargetNode = ""
  27. ' ** Parse Command Line
  28. ' Loop through arguments
  29. While ArgCount < Wscript.Arguments.Count
  30. ' Determine switches used
  31. Select Case Wscript.Arguments(ArgCount)
  32. Case "-h", "-?", "/?":
  33. Call UsageMsg
  34. Case Else: ' specifying what ADsPath to look at
  35. If TargetNode <> "" Then ' only one name at a time
  36. Call UsageMsg
  37. Else
  38. TargetNode = Wscript.Arguments(ArgCount)
  39. End If
  40. End Select
  41. ' Move pointer to next argument
  42. ArgCount = ArgCount + 1
  43. Wend
  44. ' Get main logging module list object
  45. Set ModListObj = GetObject("IIS://LocalHost/Logging")
  46. If Err.Number <> 0 Then ' Error!
  47. WScript.Echo "Error: Couldn't GetObject /Localhost/Logging."
  48. Wscript.Quit(1)
  49. End If
  50. ' LIST ALL MODULES
  51. If TargetNode = "" Then
  52. WScript.Echo "Logging modules available at IIS://LocalHost/Logging node:"
  53. ' Loop through listed logging modules
  54. For Each ChildObj in ModListObj
  55. ' break out module friendly name from path
  56. LogNameStr = ChildObj.Name
  57. Wscript.Echo "Logging module '" & LogNameStr & "':"
  58. Wscript.Echo " Module ID: " & ChildObj.LogModuleId
  59. Wscript.Echo " Module UI ID: " & ChildObj.LogModuleUiId
  60. Next
  61. Wscript.Quit(0)
  62. Else
  63. ' LIST MODULES FOR GIVEN NODE
  64. Set SObj = GetObject(TargetNode)
  65. ' Some error checking ...
  66. If Err.Number <> 0 Then ' Error!
  67. WScript.Echo "Error: Couldn't GetObject " & TargetNode & "."
  68. Wscript.Quit(1)
  69. End If
  70. If SObj.LogPluginClsId = "" Then ' Not the right type of object
  71. Wscript.Echo "Error: Object does not support property LogPluginClsId."
  72. Wscript.Quit(1)
  73. End If
  74. ' **MAIN LOOP to find the correct logging module
  75. For Each ChildObj In ModListObj
  76. If SObj.LogPluginClsId = ChildObj.LogModuleId Then ' Compare CLSIDs
  77. Set RealModObj = ChildObj
  78. End If
  79. Next
  80. ' Code could be added here, in case module ID returned is invalid ...
  81. ' Display Results
  82. WScript.Echo "Logging module in use by '" & SObj.ADsPath & "':"
  83. Wscript.Echo " Logging module: " & RealModObj.Name
  84. Wscript.Echo " Logging module ID: " & RealModObj.LogModuleId
  85. Wscript.Echo " Logging module UI ID: " & RealModObj.LogModuleUiId
  86. End If
  87. ' Displays usage message, then QUITS
  88. Sub UsageMsg
  89. Wscript.Echo "Usage: cscript logenum.vbs [<adspath>]"
  90. Wscript.Quit
  91. End Sub