<script>
function button1_onclick() {//cpu 信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_Processor");
var e = new Enumerator (properties);
var infoObj = document.getElementById("info");
var infoStr = "<table border=1>";
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
infoStr+="<tr><td>Caption-" + p.Caption + "</td></tr>";
infoStr+="<tr><td>DeviceID-" + p.DeviceID + "</td></tr>";
infoStr+="<tr><td>Name-" + p.Name + "</td></tr>";
infoStr+="<tr><td>CpuStatus-" + p.CpuStatus + "</td></tr>";
infoStr+="<tr><td>Availability-" + p.Availability + "</td></tr>";
infoStr+="<tr><td>Level-" + p.Level + "</td></tr>";
infoStr+="<tr><td>ProcessorID-" + p.ProcessorID + "</td></tr>";
infoStr+="<tr><td>SystemName-" + p.SystemName + "</td></tr>";
infoStr+="<tr><td>ProcessorType-" + p.ProcessorType + "</td></tr>";
infoStr+="<tr><td>Architecture-" + p.Architecture + "</td></tr>";
infoStr+="<tr><td>ConfigManagerErrorCode-" + p.ConfigManagerErrorCode + "</td></tr>";
}
infoStr += "</table>";
infoObj.innerHTML=infoStr;
}
function Button2_onclick() {//CD-ROM 信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_CDROMDrive");
var e = new Enumerator (properties);
var infoObj = document.getElementById("info");
var infoStr = "<table border=1>";
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
infoStr+="<tr><td>Caption-" + p.Caption + "</td></tr>";
infoStr+="<tr><td>Description-" + p.Description + "</td></tr>";
infoStr+="<tr><td>Drive-" + p.Drive + "</td></tr>";
infoStr+="<tr><td>Status-" + p.Status + "</td></tr>";
infoStr+="<tr><td>MediaLoaded-" + p.MediaLoaded + "</td></tr>";
}
infoStr += "</table>";
infoObj.innerHTML=infoStr;
}
function Button3_onclick() {//键盘信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_Keyboard");
var e = new Enumerator (properties);
var infoObj = document.getElementById("info");
var infoStr = "<table border=1>";
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
infoStr+="<tr>";
infoStr+="<td>Description " + p.Description + "</td>";
infoStr+="<td>Name " + p.Name + "</td>";
infoStr+="<td>Status " + p.Status + "</td>";
infoStr+="</tr>";
}
infoStr += "</table>";
infoObj.innerHTML=infoStr;
}
function Button4_onclick() {//主板信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_BaseBoard");
var e = new Enumerator (properties);
var infoObj = document.getElementById("info");
var infoStr = "<table border=1>";
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
infoStr+="<tr>";
infoStr+="<td>HostingBoard " + p.HostingBoard + "</td>";
infoStr+="<td>Manufacturer " + p.Manufacturer + "</td>";
infoStr+="<td>PoweredOn " + p.PoweredOn + "</td>";
infoStr+="<td>Product " + p.Product + "</td>";
infoStr+="<td>SerialNumber " + p.SerialNumber + "</td>";
infoStr+="<td>Version " + p.Version + "</td>";
infoStr+="</tr>";
}
infoStr += "</table>";
infoObj.innerHTML=infoStr;
}
</script>
<body>
<input type=button value='cpu 信息' onclick="button1_onclick()">
<input type=button value='CD-ROM 信息' onclick="Button2_onclick()">
<input type=button value='键盘信息' onclick="Button3_onclick()">
<input type=button value='主板信息' onclick="Button4_onclick()">
<div id=info>
...
</div>
</body>
通过js获取系统信息
最新推荐文章于 2022-11-10 22:48:13 发布