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.
 
 
 
 
 
 

82 lines
2.5 KiB

<HTML>
<HEAD>
<TITLE>ATL 3.0 test page for object WMIObjectBroker</TITLE>
<OBJECT ID="staticbroker" CLASSID="CLSID:4BA59771-8FBF-4E67-9917-3BBB39B743AB"></OBJECT>
</HEAD>
<BODY>
Click <SPAN id=span1><b>HERE</b></SPAN> for VBScript with dynamically allocated broker<br>
Click <SPAN id=span2><b>HERE</b></SPAN> for JScript with dynamically allocated broker<br>
Click <SPAN id=span3><b>HERE</b></SPAN> for VBScript with static broker<br>
Click <SPAN id=span4><b>HERE</b></SPAN> for JScript with static broker<br>
Click <SPAN id=span5><b>HERE</b></SPAN> to test CanCreateObject<br>
Click <SPAN id=span6><b>HERE</b></SPAN> to Register this page<br>
Click <SPAN id=span7><b>HERE</b></SPAN> to UnRegister this page<br>
<SCRIPT LANGUAGE="JSCRIPT">
// This function is passed a locator and displayes a message
// box that lists all running services.
function UseLocator(locator)
{
var service = locator.ConnectServer();
var procs = service.InstancesOf("Win32_Process");
var f = new Enumerator(procs);
sz = "";
for (;!f.atEnd();f.moveNext())
{
var proc = f.item();
sz += proc["Name"] + "\r\n";
}
alert(sz);
}
</SCRIPT>
<SCRIPT LANGUAGE="VBScript">
sub span1_onclick
dim broker
dim obj
set broker = CreateObject("WMIScriptUtils.WMIObjectBroker")
set obj = broker.CreateObject("WbemScripting.SWbemLocator")
UseLocator obj
end sub
sub span3_onclick
dim obj
set obj = staticbroker.CreateObject("WbemScripting.SWbemLocator")
UseLocator obj
end sub
</SCRIPT>
<SCRIPT LANGUAGE="JSCRIPT">
function span2.onclick()
{
var broker = new ActiveXObject("WMIScriptUtils.WMIObjectBroker");
var obj = staticbroker.CreateObject("WbemScripting.SWbemLocator");
UseLocator(obj)
}
function span4.onclick()
{
var obj = staticbroker.CreateObject("WbemScripting.SWbemLocator");
UseLocator(obj)
}
function span5.onclick()
{
alert(staticbroker.CanCreateObject("WbemScripting.SWbemLocator"));
var broker = new ActiveXObject("WMIScriptUtils.WMIObjectBroker");
alert(broker.CanCreateObject("WbemScripting.SWbemLocator"));
}
function span6.onclick()
{
var registrar = new ActiveXObject("WMIScriptUtils.WMIObjectBrokerRegistration");
var b = registrar.Register("WbemScripting.SWbemLocator");
alert(b);
}
function span7.onclick()
{
var registrar = new ActiveXObject("WMIScriptUtils.WMIObjectBrokerRegistration");
var b = registrar.UnRegister("WbemScripting.SWbemLocator");
alert(b);
}
</SCRIPT>
</BODY>
</HTML>