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

  1. /*********************************************
  2. *
  3. *  Document Footer Utility   
  4. *
  5. **********************************************
  6. *  Description:
  7. *  ------------
  8. *  This sample admin script allows you to configure document footers.
  9. *
  10. *  To Run:  
  11. *  -------
  12. *  This is the format for this script:
  13. *  
  14. *      cscript metaback.js 
  15. *  
  16. *  NOTE:  If you want to execute this script directly from Windows, use 
  17. *  'wscript' instead of 'cscript'. 
  18. *
  19. **********************************************/
  20.  
  21.  
  22. // Initialize variables
  23. var ArgCount, InputError, FootEnabled, FootDoc, FootPath, ThisObj, EnableModify, ClearFlag;
  24.  
  25. // Default values
  26. ArgCount = 0;
  27. FootPath = "";  // This MUST be set by user via command-line
  28. FootDoc = "";
  29. FootEnabled = false;
  30. EnableModify = false;
  31. ClearFlag = false;
  32.  
  33.  
  34.   // ** Parse Command Line
  35.  
  36.     // Loop through arguments
  37.     while (ArgCount < WScript.arguments.length)   {
  38.       
  39.        
  40.       // Determine switches used
  41.       switch (WScript.arguments.item(ArgCount))   {
  42.  
  43.          case "-s":   // Sets default footer explicitly to string
  44.             // Move to next arg, which should be parameter
  45.             ++ArgCount;
  46.             if (ArgCount >= WScript.arguments.length)    
  47.                UsageMsg();
  48.             else
  49.                FootDoc = "STRING:" + WScript.arguments.item(ArgCount);
  50.             break;
  51.  
  52.          case "-f":   // Sets default footer to a file
  53.             // Move to next arg, which should be parameter
  54.             ++ArgCount;
  55.             if (ArgCount >= WScript.arguments.length)
  56.                UsageMsg();
  57.             else
  58.                FootDoc = "FILE:" + WScript.arguments.item(ArgCount);
  59.             break;
  60.  
  61.          case "+d":  // Enables doc footers
  62.             FootEnabled = true;
  63.             EnableModify = true;
  64.             break;
  65.  
  66.          case "-d":  // Disables doc footers
  67.             FootEnabled = false;
  68.             EnableModify = true;
  69.             break;
  70.  
  71.          case "-c":  // Clears all document footer settings from node
  72.             ClearFlag = true;
  73.             break;
  74.  
  75.          case "-h":  // Help!
  76.             UsageMsg();
  77.             break;
  78.  
  79.          default:  // ADsPath, we hope 
  80.             if (FootPath != "")     // Only one name allowed
  81.                UsageMsg();
  82.             else
  83.                FootPath = WScript.arguments.item(ArgCount);
  84.            
  85.  
  86.       }
  87.  
  88.       // Move pointer to next argument
  89.       ++ArgCount;
  90.  
  91.     }
  92.  
  93.   // Quick screen to make sure input is valid
  94.   if (FootPath == "")  
  95.       UsageMsg();
  96.  
  97.     
  98.   // **Perform Backup:
  99.   // First, create instance of ADSI object
  100.   ADSIObj = GetObject(FootPath);
  101.  
  102.   // If no changes, then simply display current settings
  103.   if ( (!EnableModify) && (FootDoc == "") && (!ClearFlag) )  {  
  104.     if (ADSIObj.EnableDocFooter == true) 
  105.        WScript.echo(FootPath + ": Footers currently enabled, value = " + ADSIObj.DefaultDocFooter);
  106.     else
  107.        WScript.echo(FootPath + ": Footers currently disabled, value = " + ADSIObj.DefaultDocFooter);
  108.     
  109.     WScript.quit();
  110.   }
  111.  
  112.   // Otherwise, perform changes 
  113.   if (ClearFlag)   {  
  114.      ADSIObj.EnableDocFooter = false;
  115.      ADSIObj.DefaultDocFooter = "";
  116.   }
  117.   else  {
  118.      if (EnableModify)
  119.          ADSIObj.EnableDocFooter = FootEnabled;
  120.      if (FootDoc != "")  
  121.          ADSIObj.DefaultDocFooter = FootDoc ;
  122.   }
  123.  
  124.   // Save new settings back to Metabase
  125.   ADSIObj.SetInfo();
  126.  
  127.   // Display results
  128.   if (ADSIObj.EnableDocFooter) 
  129.      WScript.echo(FootPath + ": Document footers enabled, value = " + ADSIObj.DefaultDocFooter);
  130.   else
  131.     WScript.echo(FootPath + ": Document footers disabled, value = " + ADSIObj.DefaultDocFooter);
  132.  
  133.  
  134.  
  135.  
  136. // Displays usage message, then QUITS
  137. function UsageMsg()  {
  138.     WScript.echo("Usage:  cscript dfoot.js <ADsPath> [+d|-d footers enabled] [[-s <string>] | [-f <filename>]] [-c to clear]");
  139.     WScript.quit();
  140. }
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.