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.

106 lines
2.3 KiB

  1. '''''''''''''''''''''''''''''''''''''''''''''
  2. '
  3. ' Metabase Backup Enumeration Utility
  4. '
  5. '''''''''''''''''''''''''''''''''''''''''''''
  6. ' Description:
  7. ' ------------
  8. ' This sample admin script allows you to list current versions of Metabase backups.
  9. '
  10. ' To Run:
  11. ' -------
  12. ' This is the format for this script:
  13. '
  14. ' cscript metabackenum.vbs
  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, BuNameIn, BuVersionOut, BuNameOut, BuCount, BuDateOut
  24. ' Default values
  25. ArgCount = 0
  26. BuNameIn = "" ' All backup location names returned
  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", "-?", "/?": ' Help!
  33. Call UsageMsg
  34. Case Else:
  35. If BuNameIn <> "" Then ' Only one name allowed
  36. Call UsageMsg
  37. Else
  38. BuNameIn = Wscript.Arguments(ArgCount)
  39. End If
  40. End Select
  41. ' Move pointer to next argument
  42. ArgCount = ArgCount + 1
  43. Wend
  44. ' **Enumerate Backups:
  45. ' First, create instance of computer object
  46. Set CompObj = GetObject("IIS://Localhost")
  47. If BuNameIn = "" Then
  48. Wscript.Echo "Backups available, all location names: "
  49. Else
  50. Wscript.Echo "Backups available for '" & BuNameIn & "': "
  51. End If
  52. ' Initialize counter
  53. BuCount = 0
  54. ' Loop through items returned by EnumBackups
  55. Do While True
  56. CompObj.EnumBackups BuNameIn, BuCount, BuVersionOut , BuNameOut, BuDateOut
  57. ' Sniff to see if end of internal array has been reached
  58. If Err.Number <> 0 Then
  59. Exit Do
  60. End If
  61. ' Make output pretty
  62. If BuVersionOut = "" Then
  63. BuVersionOut = 0
  64. End If
  65. ' Display Findings
  66. Wscript.Echo BuNameOut & " (version " & BuVersionOut & ") -- " & BuDateOut & "."
  67. ' Bump counter
  68. BuCount = BuCount + 1
  69. Loop
  70. ' Displays usage message, and then QUITS
  71. Sub UsageMsg
  72. Wscript.Echo "Usage: cscript metabackenum.vbs [<backupname>]"
  73. Wscript.Quit
  74. End Sub