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.

105 lines
2.5 KiB

  1. /*********************************************
  2. *
  3. * Metabase Backup Utility
  4. *
  5. *********************************************
  6. *
  7. * Description:
  8. * ------------
  9. * This sample admin script allows you to create a backup of your Metabase.
  10. *
  11. * To Run:
  12. * -------
  13. * This is the format for this script:
  14. *
  15. * cscript metaback.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, BuFlags, CompObj, VersionMsg;
  23. // Default values
  24. ArgCount = 0;
  25. BuName= "SampleBackup";
  26. BuVersion = -1; // Use next available version number
  27. BuFlags = 0; // No special flags
  28. // ** Parse Command Line
  29. // Loop through arguments
  30. while (ArgCount < WScript.arguments.Length) {
  31. // Determine switches used
  32. switch (WScript.arguments.item(ArgCount)) {
  33. case "-v": // Designate backup version number
  34. // Move to next arg, which should be parameter
  35. ++ArgCount;
  36. if (ArgCount >= WScript.arguments.length)
  37. UsageMsg();
  38. else
  39. BuVersion = WScript.arguments.item(ArgCount);
  40. break;
  41. case "-F": // Force overwrite, even if name and version exists
  42. BuFlags = 1;
  43. break;
  44. case "-h":
  45. case "-?":
  46. case "/?":
  47. UsageMsg();
  48. break;
  49. default:
  50. if (BuName != "SampleBackup") // Only one name allowed
  51. UsageMsg();
  52. else
  53. BuName = WScript.arguments.item(ArgCount);
  54. }
  55. // Move pointer to next argument
  56. ++ArgCount;
  57. }
  58. // **Perform Backup:
  59. // First, create instance of computer object
  60. CompObj = GetObject("IIS://Localhost");
  61. // Call Backup method, with appropriate parameters
  62. CompObj.Backup(BuName, BuVersion, BuFlags);
  63. // Make pretty version string
  64. if (BuVersion == -1)
  65. VersionMsg = "next version";
  66. else
  67. VersionMsg = "version " + BuVersion;
  68. if (BuFlags == 1) // Forced creation
  69. WScript.echo("Force created: Backup '" + BuName + "' (" + VersionMsg + ").");
  70. else
  71. WScript.echo("Created: Backup '" + BuName + "' (" + VersionMsg + ").");
  72. // Displays usage message, then QUITS
  73. function UsageMsg() {
  74. WScript.echo("Usage: cscript metaback.js [<backupname>][-v <versionnum>][-F (to force)]");
  75. WScript.quit();
  76. }