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

  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. *  NOTE:  If you want to execute this script directly from Windows, use 
  18. *  'wscript' instead of 'cscript'. 
  19. *
  20. **********************************************/
  21.  
  22.  
  23.  
  24. // Initialize variables
  25. var ArgCount, TargetNode, InProcFlag, FriendlyName, FlagMsg;
  26. var DirObj;
  27.  
  28. // Default values
  29. ArgCount = 0;
  30. TargetNode = "";
  31. InProcFlag = true;
  32. FriendlyName = "MyNewApp";
  33.  
  34.  
  35.  
  36.   // ** Parse Command Line
  37.  
  38.     // Loop through arguments
  39.     while (ArgCount < WScript.arguments.length)   {
  40.       
  41.       // Determine switches used
  42.       switch (WScript.arguments.item(ArgCount))   {
  43.  
  44.          case "-n":
  45.             // Move to next arg, which should be parameter
  46.             ArgCount =  ArgCount + 1;
  47.             if (ArgCount >= WScript.arguments.length)  
  48.                UsageMsg();
  49.             else
  50.                FriendlyName = WScript.arguments.item(ArgCount);
  51.             break;
  52.  
  53.          case "-I":
  54.             InProcFlag = false;
  55.             break;
  56.  
  57.          case "-h":
  58.          case "-?":
  59.          case "/?":
  60.             UsageMsg();
  61.             break;
  62.  
  63.          default:    // specifying what ADsPath to look at
  64.             if (TargetNode != "")   // only one name at a time
  65.                 UsageMsg();
  66.             else
  67.                 TargetNode = WScript.arguments.item(ArgCount);
  68.            
  69.  
  70.       }
  71.  
  72.       // Move pointer to next argument
  73.       ++ArgCount;
  74.  
  75.     }
  76.  
  77.  
  78.   // Make sure they've specified a path
  79.   if (TargetNode == "")   
  80.      UsageMsg();
  81.   
  82.   // Get ADSI object for target node
  83.   DirObj = GetObject(TargetNode);
  84.  
  85.   // Create application
  86.   DirObj.AppCreate(InProcFlag);
  87.  
  88.   // Set friendly name for application 
  89.   DirObj.AppFriendlyName = FriendlyName;
  90.  
  91.   // Write new info back to Metabase
  92.   DirObj.SetInfo();
  93.  
  94.   // Make pretty string
  95.   if (InProcFlag == true)  
  96.      FlagMsg = "in-process";
  97.   else
  98.      FlagMsg = "isolated";
  99.  
  100.  
  101.   // Success!
  102.   WScript.echo("Created:  Application '" + FriendlyName + "' (" + FlagMsg + ").");
  103.  
  104.  
  105.  
  106. // Displays usage message, then QUITS
  107. function UsageMsg()  {
  108.    WScript.echo("Usage:    cscript appcreate.js <adspath> [-n <friendlyname>][-I (to isolate)]");
  109.    WScript.quit();
  110. }
  111.  
  112.  
  113.  
  114.  
  115.