|
function gatherProcessorInfo()
{
var fc = new Enumerator(runQuery("Win32_Processor"));
var xmlDoc = null;
var colItem = null;
var numItems = 0;
for (; !fc.atEnd(); fc.moveNext())
{
numItems++;
}
fc.moveFirst();
if(numItems > 0)
{
xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
if(numItems > 1)
{
colItem = xmlDoc.createElement("Item");
xmlAttachChildToParent(xmlDoc, colItem);
xmlSetAttribute(xmlDoc, colItem, "name", "Processors");
}
var i = 1;
for (; !fc.atEnd(); fc.moveNext())
{
var Obj = fc.item();
var root, num = "";
if(colItem != null)
{
root = xmlDoc.createElement("Element");
num = " " + String(i);
}
else
{
root = xmlDoc.createElement("Item");
}
xmlSetAttribute(xmlDoc, root, "name", "Processor" + num);
if(colItem != null)
{
xmlAttachChildToParent(colItem, root);
}
else
{
xmlAttachChildToParent(xmlDoc, root);
}
xmlCreateChildTextNode(xmlDoc, root, "Architecture", Obj.Architecture);
xmlCreateChildTextNode(xmlDoc, root, "Availability", translate_availability(Obj.Availability));
xmlCreateChildTextNode(xmlDoc, root, "Caption", Obj.Caption);
xmlCreateChildTextNodeWithAttribute(xmlDoc, root, "CpuStatus", Obj.CpuStatus, "name", "CPU status");
xmlCreateChildTextNodeWithAttribute(xmlDoc, root, "CurrentClockSpeed", Obj.CurrentClockSpeed, "name", "Current clock speed");
xmlCreateChildTextNodeWithAttribute(xmlDoc, root, "CurrentVoltage", Obj.CurrentVoltage, "name", "Current voltage");
xmlCreateChildTextNodeWithAttribute(xmlDoc, root, "DeviceID", Obj.DeviceID, "name", "Device ID");
xmlCreateChildTextNode(xmlDoc, root, "Family", Obj.Family);
xmlCreateChildTextNode(xmlDoc, root, "Manufacturer", Obj.Manufacturer);
xmlCreateChildTextNodeWithAttribute(xmlDoc, root, "MaxClockSpeed", Obj.MaxClockSpeed, "name", "Maximum clock speed");
xmlCreateChildTextNode(xmlDoc, root, "Name", Obj.Name);
xmlCreateChildTextNodeWithAttribute(xmlDoc, root, "ProcessorId", Obj.ProcessorId, "name", "Processor ID");
xmlCreateChildTextNodeWithAttribute(xmlDoc, root, "ProcessorType", Obj.ProcessorType, "name", "Processor type");
xmlCreateChildTextNode(xmlDoc, root, "Revision", Obj.Revision);
xmlCreateChildTextNode(xmlDoc, root, "Role", Obj.Role);
xmlCreateChildTextNodeWithAttribute(xmlDoc, root, "SocketDesignation", Obj.SocketDesignation, "name", "Socket type");
xmlCreateChildTextNode(xmlDoc, root, "Status", Obj.Status);
xmlCreateChildTextNode(xmlDoc, root, "Version", Obj.Version);
i++;
}
}
return xmlDoc;
}
-- modified at 6:29 Thursday 19th January, 2006
|
|
|
|
|
Ok. It works fine.
Thanks a lot, Dmitry.
|
|
|
|
|
Hi everyone!
glucks & hasherfrog - thank you guys for comments. All errors are really withing the gatherProsessorInfo() (probably when running the script on a multiprocessor or HyperThreading-enabled machine). The correct routine 'll be in the next post.
|
|
|
|
|
Yes, some error is occured in gatherProcessorInfo();
Great job. Very useful for admins :]
|
|
|
|
|
Hi,
great Article!
However i've got an error using the script on local computer (XP pro SP2).
"
Windows Script Host
Script: E:\tmp\wmiadmin.js
Line: 144
Char: 3
Error: Only one top level element is allowed in an XML document.
Code: 80004005
Source: msxml3.dll
"
This is the function "xmlAttachChildToParent(parent, child)".
The output file "result-127-0-0-1.xml" is empty (0 Bytes).
Do you have any Idea how i can make it work?
I have admin privileges on local machine.
Regards,
glucks
|
|
|
|
|
Nice to have all the object available, too
|
|
|
|