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.

104 lines
2.3 KiB

  1. /*********************************************
  2. *
  3. * Metabase Backup Deletion Utility
  4. *
  5. **********************************************
  6. *
  7. * Description:
  8. * ------------
  9. * This sample admin script allows you to delete a Metabase backup.
  10. *
  11. * To Run:
  12. * -------
  13. * This is the format for this script:
  14. *
  15. * cscript metabackdel.js
  16. *
  17. * NOTE: If you want to execute this script directly from Windows, use
  18. * 'wscript' instead of 'cscript'.
  19. *
  20. *********************************************/
  21. // Initialize variables
  22. var ArgCount, BuName, BuVersion, CompObj, VersionMsg;
  23. var Args;
  24. // Default values
  25. ArgCount = 0;
  26. BuName = ""; // Default backup, but will not be allowed
  27. BuVersion = -2; // Designates highest existing version
  28. // ** Parse Command Line
  29. // Loop through arguments
  30. WScript.echo("VAlue of args: " + WScript.Arguments.length);
  31. while (ArgCount < WScript.Arguments.length) {
  32. // Determine switches used
  33. switch (WScript.arguments.item(ArgCount)) {
  34. case "-v": // Designate backup version to be deleted
  35. // Move to next arg, which should be parameter
  36. ArgCount = ArgCount + 1 ;
  37. if (ArgCount >= WScript.arguments.length)
  38. UsageMsg();
  39. else
  40. BuVersion = WScript.arguments.item(ArgCount);
  41. break;
  42. case "-h", "/?", "-?":
  43. UsageMsg();
  44. break;
  45. default:
  46. if (BuName != "") // Only one name allowed
  47. UsageMsg();
  48. else
  49. BuName = WScript.arguments.item(ArgCount);
  50. }
  51. // Move pointer to next argument
  52. ++ArgCount;
  53. }
  54. // If no location name was selected, generate usage message
  55. if (BuName == "") {
  56. UsageMsg();
  57. }
  58. // Get instance of computer object
  59. CompObj = GetObject("IIS://Localhost");
  60. // Try to delete backup
  61. CompObj.DeleteBackup(BuName, BuVersion);
  62. // Make version string pretty
  63. if (BuVersion == -2)
  64. VersionMsg = "highest version";
  65. else
  66. VersionMsg = "version " + BuVersion;
  67. WScript.echo("Backup deleted: '" + BuName + "' (" + VersionMsg + ").");
  68. // Displays usage message, then QUITS
  69. function UsageMsg() {
  70. WScript.echo("Usage: cscript metabackdel.js <backupname> [-v <versionnum>]");
  71. WScript.Quit();
  72. }