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

  1. /*********************************************
  2. *
  3. *  Logging Module Enumeration Utility
  4. *
  5. **********************************************
  6. *  Description:
  7. *  ------------
  8. *  This sample admin script allows you configure logging services for IIS.
  9. *
  10. *  To Run:  
  11. *  -------
  12. *  This is the format for this script:
  13. *  
  14. *      cscript logenum.js [<adspath>]
  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, TargetNode, SObj, ModListObj, ChildObj, RealModObj, LogNameStr, AllObjs;
  24.  
  25. // Default values
  26. ArgCount = 0;
  27. TargetNode = "";
  28.  
  29.  
  30.  
  31.   // ** Parse Command Line
  32.  
  33.     // Loop through arguments
  34.     while (ArgCount < WScript.arguments.length)   {
  35.       
  36.       // Determine switches used
  37.       switch (WScript.arguments.item(ArgCount))   {
  38.  
  39.          case "-h":
  40.          case "-?":
  41.          case "/?":
  42.             UsageMsg();
  43.             break;
  44.  
  45.          default:    // specifying what ADsPath to look at
  46.             if (TargetNode != "")   // only one name at a time
  47.                 UsageMsg();
  48.             else
  49.                 TargetNode = WScript.arguments.item(ArgCount);
  50.  
  51.       }
  52.  
  53.       // Move pointer to next argument
  54.       ++ArgCount;
  55.  
  56.     }  // ** END argument parsing
  57.  
  58.  
  59.     // Get main logging module list object 
  60.     ModListObj = GetObject("IIS://LocalHost/Logging");
  61.  
  62.     // Create Enumerator object
  63.     AllObjs = new Enumerator(ModListObj);
  64.  
  65.     // LIST ALL MODULES
  66.     if (TargetNode == "")   {   
  67.  
  68.         WScript.echo("Logging modules available at IIS://LocalHost/Logging node:");
  69.  
  70.         // Loop through listed logging modules
  71.         while ( !AllObjs.atEnd() ) {   // Loop through collection
  72.  
  73.             // break out module friendly name from path
  74.             LogNameStr = AllObjs.item().Name;
  75.  
  76.             WScript.echo("Logging module '" + LogNameStr + "':");
  77.             WScript.echo("      Module ID: " + AllObjs.item().LogModuleId);
  78.             WScript.echo("   Module UI ID: " + AllObjs.item().LogModuleUiId);
  79.  
  80.             // Move to next member of collection
  81.             AllObjs.moveNext();
  82.         
  83.         }
  84.         
  85.         WScript.quit(0);
  86.         
  87.     }
  88.  
  89.  
  90.     else  {   // LIST MODULES FOR GIVEN NODE
  91.  
  92.        SObj = GetObject(TargetNode);
  93.  
  94.        if (SObj.LogPluginClsId == "")   {    // Not the right type of object
  95.           WScript.echo("Error:  Object does not support property LogPluginClsId.");
  96.           WScript.quit(1);
  97.        }
  98.      
  99.        // **MAIN LOOP to find the correct logging module
  100.        while ( !AllObjs.atEnd() ) {
  101.            if (SObj.LogPluginClsId == AllObjs.item().LogModuleId)   // Compare CLSIDs
  102.                RealModObj = AllObjs.item();
  103.            
  104.            // Move to next member
  105.            AllObjs.moveNext();
  106.        }
  107.     
  108.  
  109.        // Display Results
  110.        WScript.echo("Logging module in use by '" + SObj.ADsPath + "':");
  111.        WScript.echo("       Logging module: " + RealModObj.Name);
  112.        WScript.echo("    Logging module ID: " + RealModObj.LogModuleId);
  113.        WScript.echo(" Logging module UI ID: " + RealModObj.LogModuleUiId);
  114.  
  115.    }
  116.  
  117.  
  118.  
  119.  
  120. // Displays usage message, then QUITS
  121. function UsageMsg()  {
  122.    WScript.echo("Usage:  cscript logenum.js [<adspath>]" );
  123.    WScript.quit();
  124. }
  125.  
  126.