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.

125 lines
3.2 KiB

  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. // Initialize variables
  21. var ArgCount, TargetNode, SObj, ModListObj, ChildObj, RealModObj, LogNameStr, AllObjs;
  22. // Default values
  23. ArgCount = 0;
  24. TargetNode = "";
  25. // ** Parse Command Line
  26. // Loop through arguments
  27. while (ArgCount < WScript.arguments.length) {
  28. // Determine switches used
  29. switch (WScript.arguments.item(ArgCount)) {
  30. case "-h":
  31. case "-?":
  32. case "/?":
  33. UsageMsg();
  34. break;
  35. default: // specifying what ADsPath to look at
  36. if (TargetNode != "") // only one name at a time
  37. UsageMsg();
  38. else
  39. TargetNode = WScript.arguments.item(ArgCount);
  40. }
  41. // Move pointer to next argument
  42. ++ArgCount;
  43. } // ** END argument parsing
  44. // Get main logging module list object
  45. ModListObj = GetObject("IIS://LocalHost/Logging");
  46. // Create Enumerator object
  47. AllObjs = new Enumerator(ModListObj);
  48. // LIST ALL MODULES
  49. if (TargetNode == "") {
  50. WScript.echo("Logging modules available at IIS://LocalHost/Logging node:");
  51. // Loop through listed logging modules
  52. while ( !AllObjs.atEnd() ) { // Loop through collection
  53. // break out module friendly name from path
  54. LogNameStr = AllObjs.item().Name;
  55. WScript.echo("Logging module '" + LogNameStr + "':");
  56. WScript.echo(" Module ID: " + AllObjs.item().LogModuleId);
  57. WScript.echo(" Module UI ID: " + AllObjs.item().LogModuleUiId);
  58. // Move to next member of collection
  59. AllObjs.moveNext();
  60. }
  61. WScript.quit(0);
  62. }
  63. else { // LIST MODULES FOR GIVEN NODE
  64. SObj = GetObject(TargetNode);
  65. if (SObj.LogPluginClsId == "") { // Not the right type of object
  66. WScript.echo("Error: Object does not support property LogPluginClsId.");
  67. WScript.quit(1);
  68. }
  69. // **MAIN LOOP to find the correct logging module
  70. while ( !AllObjs.atEnd() ) {
  71. if (SObj.LogPluginClsId == AllObjs.item().LogModuleId) // Compare CLSIDs
  72. RealModObj = AllObjs.item();
  73. // Move to next member
  74. AllObjs.moveNext();
  75. }
  76. // Display Results
  77. WScript.echo("Logging module in use by '" + SObj.ADsPath + "':");
  78. WScript.echo(" Logging module: " + RealModObj.Name);
  79. WScript.echo(" Logging module ID: " + RealModObj.LogModuleId);
  80. WScript.echo(" Logging module UI ID: " + RealModObj.LogModuleUiId);
  81. }
  82. // Displays usage message, then QUITS
  83. function UsageMsg() {
  84. WScript.echo("Usage: cscript logenum.js [<adspath>]" );
  85. WScript.quit();
  86. }