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.

89 lines
2.4 KiB

  1. '------------------------------------------------------------------------------------------------
  2. '
  3. ' Print the tree of administration objects starting either at the specified node or the root
  4. ' node of the local machine.
  5. '
  6. ' Usage: disptree [--ADSPath|-a ROOT NODE]
  7. ' [--NoRecurse|-n]
  8. ' [--help|-?]
  9. '
  10. ' ROOT NODE Optional argument specifies the ADSI path of the first node of the tree
  11. ' No Recurse Specifying this keeps the script from recursing through the tree
  12. '
  13. ' Example 1: disptree
  14. ' Example 2: disptree -a IIS://LocalHost/w3svc --NoRecurse
  15. '------------------------------------------------------------------------------------------------
  16. ' Force declaration of variables.
  17. Option Explicit
  18. On Error Resume Next
  19. Dim oFirstNode, Recurse, CurrentObj, RootNodePath
  20. ' By default, we recurse.
  21. Recurse = True
  22. ' Set the default path
  23. RootNodePath = "IIS://LocalHost"
  24. Dim oArgs, ArgNum
  25. Set oArgs = WScript.Arguments
  26. ArgNum = 0
  27. While ArgNum < oArgs.Count
  28. Select Case LCase(oArgs(ArgNum))
  29. Case "--adspath","-a":
  30. ArgNum = ArgNum + 1
  31. RootNodePath = oArgs(ArgNum)
  32. Case "--norecurse","-n":
  33. Recurse = false
  34. Case "--help","-?":
  35. Call DisplayUsage
  36. Case Else:
  37. Call DisplayUsage
  38. End Select
  39. ArgNum = ArgNum + 1
  40. Wend
  41. Set oFirstNode = GetObject(RootNodePath)
  42. If Err <> 0 Then
  43. Display "Couldn't get the first node!"
  44. WScript.Quit (1)
  45. End If
  46. ' Begin displaying tree
  47. Call DisplayTree(oFirstNode, 0)
  48. ' This is the sub that will do the actual recursion
  49. Sub DisplayTree(FirstObj, Level)
  50. If (FirstObj.Class = "IIsWebServer") Or (FirstObj.Class = "IIsFtpServer") Then
  51. WScript.Echo Space(Level*2) & FirstObj.Name & " - " & FirstObj.ServerComment & " (" & FirstObj.Class & ")"
  52. Else
  53. WScript.Echo Space(Level*2) & FirstObj.Name & " (" & FirstObj.Class & ")"
  54. End If
  55. ' Only recurse if so specified.
  56. If (Level = 0) or (Recurse) then
  57. For Each CurrentObj in FirstObj
  58. Call DisplayTree(CurrentObj, Level + 1)
  59. Next
  60. End If
  61. End Sub
  62. ' Display the usage for this script
  63. Sub DisplayUsage
  64. WScript.Echo "Usage: disptree [--ADSPath|-a ROOT NODE]"
  65. WScript.Echo " [--NoRecurse|-n]"
  66. WScript.Echo " [--Help|-?]"
  67. WScript.Echo ""
  68. WScript.Echo " Example 1: disptree"
  69. WScript.Echo " Example 2: disptree -a IIS://LocalHost/w3svc --NoRecurse"
  70. WSCript.Quit
  71. End Sub
  72. Sub Display(Msg)
  73. WScript.Echo Now & ". Error Code: " & Err & " --- " & Msg
  74. End Sub