Leaked source code of windows server 2003
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.

81 lines
2.5 KiB

  1. <HTML>
  2. <HEAD>
  3. <TITLE>ATL 3.0 test page for object WMIObjectBroker</TITLE>
  4. <OBJECT ID="staticbroker" CLASSID="CLSID:4BA59771-8FBF-4E67-9917-3BBB39B743AB"></OBJECT>
  5. </HEAD>
  6. <BODY>
  7. Click <SPAN id=span1><b>HERE</b></SPAN> for VBScript with dynamically allocated broker<br>
  8. Click <SPAN id=span2><b>HERE</b></SPAN> for JScript with dynamically allocated broker<br>
  9. Click <SPAN id=span3><b>HERE</b></SPAN> for VBScript with static broker<br>
  10. Click <SPAN id=span4><b>HERE</b></SPAN> for JScript with static broker<br>
  11. Click <SPAN id=span5><b>HERE</b></SPAN> to test CanCreateObject<br>
  12. Click <SPAN id=span6><b>HERE</b></SPAN> to Register this page<br>
  13. Click <SPAN id=span7><b>HERE</b></SPAN> to UnRegister this page<br>
  14. <SCRIPT LANGUAGE="JSCRIPT">
  15. // This function is passed a locator and displayes a message
  16. // box that lists all running services.
  17. function UseLocator(locator)
  18. {
  19. var service = locator.ConnectServer();
  20. var procs = service.InstancesOf("Win32_Process");
  21. var f = new Enumerator(procs);
  22. sz = "";
  23. for (;!f.atEnd();f.moveNext())
  24. {
  25. var proc = f.item();
  26. sz += proc["Name"] + "\r\n";
  27. }
  28. alert(sz);
  29. }
  30. </SCRIPT>
  31. <SCRIPT LANGUAGE="VBScript">
  32. sub span1_onclick
  33. dim broker
  34. dim obj
  35. set broker = CreateObject("WMIScriptUtils.WMIObjectBroker")
  36. set obj = broker.CreateObject("WbemScripting.SWbemLocator")
  37. UseLocator obj
  38. end sub
  39. sub span3_onclick
  40. dim obj
  41. set obj = staticbroker.CreateObject("WbemScripting.SWbemLocator")
  42. UseLocator obj
  43. end sub
  44. </SCRIPT>
  45. <SCRIPT LANGUAGE="JSCRIPT">
  46. function span2.onclick()
  47. {
  48. var broker = new ActiveXObject("WMIScriptUtils.WMIObjectBroker");
  49. var obj = staticbroker.CreateObject("WbemScripting.SWbemLocator");
  50. UseLocator(obj)
  51. }
  52. function span4.onclick()
  53. {
  54. var obj = staticbroker.CreateObject("WbemScripting.SWbemLocator");
  55. UseLocator(obj)
  56. }
  57. function span5.onclick()
  58. {
  59. alert(staticbroker.CanCreateObject("WbemScripting.SWbemLocator"));
  60. var broker = new ActiveXObject("WMIScriptUtils.WMIObjectBroker");
  61. alert(broker.CanCreateObject("WbemScripting.SWbemLocator"));
  62. }
  63. function span6.onclick()
  64. {
  65. var registrar = new ActiveXObject("WMIScriptUtils.WMIObjectBrokerRegistration");
  66. var b = registrar.Register("WbemScripting.SWbemLocator");
  67. alert(b);
  68. }
  69. function span7.onclick()
  70. {
  71. var registrar = new ActiveXObject("WMIScriptUtils.WMIObjectBrokerRegistration");
  72. var b = registrar.UnRegister("WbemScripting.SWbemLocator");
  73. alert(b);
  74. }
  75. </SCRIPT>
  76. </BODY>
  77. </HTML>