home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / iis4_07.cab / metabackenum.vbs < prev    next >
Text File  |  1997-10-25  |  2KB  |  107 lines

  1. '''''''''''''''''''''''''''''''''''''''''''''
  2. '
  3. '  Metabase Backup Enumeration Utility   
  4. '
  5. '''''''''''''''''''''''''''''''''''''''''''''
  6.  
  7. '  Description:
  8. '  ------------
  9. '  This sample admin script allows you to list current versions of Metabase backups.
  10. '
  11. '  To Run:  
  12. '  -------
  13. '  This is the format for this script:
  14. '  
  15. '      cscript metabackenum.vbs 
  16. '  
  17. '  NOTE:  If you want to execute this script directly from Windows, use 
  18. '  'wscript' instead of 'cscript'. 
  19. '
  20. '''''''''''''''''''''''''''''''''''''''''''''
  21.  
  22. ' Initialize error checking
  23. On Error Resume Next
  24.  
  25. ' Initialize variables
  26. Dim ArgCount, BuNameIn, BuVersionOut, BuNameOut, BuCount, BuDateOut
  27.  
  28. ' Default values
  29. ArgCount = 0
  30. BuNameIn = ""    ' All backup location names returned
  31.  
  32.  
  33.   ' ** Parse Command Line
  34.  
  35.     ' Loop through arguments
  36.     While ArgCount < Wscript.Arguments.Count
  37.  
  38.       ' Determine switches used
  39.       Select Case Wscript.Arguments(ArgCount)
  40.   
  41.  
  42.          Case "-h", "-?", "/?":   '  Help!
  43.             Call UsageMsg
  44.  
  45.          Case Else:
  46.             If BuNameIn <> "" Then ' Only one name allowed
  47.                Call UsageMsg
  48.             Else
  49.                BuNameIn = Wscript.Arguments(ArgCount)
  50.             End If
  51.  
  52.       End Select
  53.  
  54.       ' Move pointer to next argument
  55.       ArgCount = ArgCount + 1
  56.  
  57.     Wend
  58.  
  59.  
  60.   ' **Enumerate Backups:
  61.   ' First, create instance of computer object
  62.   Set CompObj = GetObject("IIS://Localhost")
  63.  
  64.   If BuNameIn = "" Then
  65.         Wscript.Echo "Backups available, all location names: "
  66.   Else
  67.         Wscript.Echo "Backups available for '" & BuNameIn & "': "
  68.   End If
  69.  
  70.   ' Initialize counter
  71.   BuCount = 0
  72.  
  73.   ' Loop through items returned by EnumBackups
  74.   Do While True
  75.         CompObj.EnumBackups BuNameIn, BuCount, BuVersionOut , BuNameOut, BuDateOut
  76.  
  77.         ' Sniff to see if end of internal array has been reached
  78.         If Err.Number <> 0 Then
  79.             Exit Do   
  80.         End If     
  81.  
  82.         ' Make output pretty
  83.         If BuVersionOut = "" Then 
  84.             BuVersionOut = 0
  85.         End If
  86.  
  87.         ' Display Findings
  88.         Wscript.Echo BuNameOut & " (version " & BuVersionOut & ") -- " & BuDateOut & "."
  89.  
  90.         ' Bump counter
  91.         BuCount = BuCount + 1
  92.   Loop
  93.  
  94.  
  95.  
  96.  
  97. ' Displays usage message, and then QUITS
  98. Sub UsageMsg 
  99.   Wscript.Echo "Usage:  cscript metabackenum.vbs [<backupname>]"
  100.   Wscript.Quit
  101. End Sub
  102.  
  103.  
  104.  
  105.  
  106.  
  107.