function getSysInfo(){
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
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};
}
在做测试时,会弹出时候允许ActiveX交互,选择允许。而在服务器上运行时可能会出现“Automation 服务器不能创建对象”的javascript错误。出现此错误时,在工具-->Internet选项-->安全-->自定义级别 -->启用"对没有标记为安全的ActiveX控件进行初始化和脚本运行",即可解决此问题