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.

115 lines
2.5 KiB

  1. /*********************************************
  2. *
  3. * Application Creation Utility
  4. *
  5. **********************************************
  6. *
  7. * Description:
  8. * ------------
  9. * This sample admin script allows you to designate a web directory or virtual directory
  10. * as an application root.
  11. *
  12. * To Run:
  13. * -------
  14. * This is the format for this script:
  15. *
  16. * cscript appcreate.js <adspath> [-n <friendlyname>][-I (to isolate)]
  17. *
  18. * NOTE: If you want to execute this script directly from Windows, use
  19. * 'wscript' instead of 'cscript'.
  20. *
  21. **********************************************/
  22. // Initialize variables
  23. var ArgCount, TargetNode, InProcFlag, FriendlyName, FlagMsg;
  24. var DirObj;
  25. // Default values
  26. ArgCount = 0;
  27. TargetNode = "";
  28. InProcFlag = true;
  29. FriendlyName = "MyNewApp";
  30. // ** Parse Command Line
  31. // Loop through arguments
  32. while (ArgCount < WScript.arguments.length) {
  33. // Determine switches used
  34. switch (WScript.arguments.item(ArgCount)) {
  35. case "-n":
  36. // Move to next arg, which should be parameter
  37. ArgCount = ArgCount + 1;
  38. if (ArgCount >= WScript.arguments.length)
  39. UsageMsg();
  40. else
  41. FriendlyName = WScript.arguments.item(ArgCount);
  42. break;
  43. case "-I":
  44. InProcFlag = false;
  45. break;
  46. case "-h":
  47. case "-?":
  48. case "/?":
  49. UsageMsg();
  50. break;
  51. default: // specifying what ADsPath to look at
  52. if (TargetNode != "") // only one name at a time
  53. UsageMsg();
  54. else
  55. TargetNode = WScript.arguments.item(ArgCount);
  56. }
  57. // Move pointer to next argument
  58. ++ArgCount;
  59. }
  60. // Make sure they've specified a path
  61. if (TargetNode == "")
  62. UsageMsg();
  63. // Get ADSI object for target node
  64. DirObj = GetObject(TargetNode);
  65. // Create application
  66. DirObj.AppCreate(InProcFlag);
  67. // Set friendly name for application
  68. DirObj.AppFriendlyName = FriendlyName;
  69. // Write new info back to Metabase
  70. DirObj.SetInfo();
  71. // Make pretty string
  72. if (InProcFlag == true)
  73. FlagMsg = "in-process";
  74. else
  75. FlagMsg = "isolated";
  76. // Success!
  77. WScript.echo("Created: Application '" + FriendlyName + "' (" + FlagMsg + ").");
  78. // Displays usage message, then QUITS
  79. function UsageMsg() {
  80. WScript.echo("Usage: cscript appcreate.js <adspath> [-n <friendlyname>][-I (to isolate)]");
  81. WScript.quit();
  82. }