new ActiveXObject ("WbemScripting.SWbemLocator") Automation 服务器不能创建对
作者:2023面试高手 | 2024-02-26 23:00:01
赞
踩
wbemscripting.swbemlocator
function getSysInfo(){
[b] var locator = new ActiveXObject ("WbemScripting.SWbemLocator"); [/b]
var service = locator.ConnectServer(".");
var cpu = new Enumerator (service.ExecQuery("SELECT * FROM Win32_Processor")).item();
var cpuType=cpu.Name,hostName=cpu.SystemName;
var memory = new Enumerator (service.ExecQuery("SELECT * FROM Win32_PhysicalMemory"));
var mem=0;
var memSpeed=0;
for (var mem=[],i=0;!memory.atEnd();memory.moveNext()){
mem+=memory.item().Capacity/1024/1024
memSpeed=memory.item().Speed;
}
var system=new Enumerator (service.ExecQuery("SELECT * FROM Win32_ComputerSystem")).item();
var physicMenCap=Math.ceil(system.TotalPhysicalMemory/1024/1024),
curUser=system.UserName,cpuCount=system.NumberOfProcessors;
return {cpuType:cpuType,hostName:hostName,curUser:curUser,memSpeed:memSpeed,mem:mem};
}