1、浏览器信息
- //浏览器信息
- function BrowserInfo() {
- var userLanguage = navigator.userLanguage; // 用户在自己的操作系统上设置的语言(火狐没有)
- var userAgent = navigator.userAgent; //包含以下属性中所有或一部分的字符串:appCodeName,appName,appVersion,language,platform
- var systemLanguage = navigator.systemLanguage; // 用户操作系统支持的默认语言(火狐没有)
- var info = "";
- info += "浏览器属性信息: " + userAgent + "<br />";
- info += "用户设置的操作系统语言: " + userLanguage + "<br />";
- info += "操作系统支持的默认语言: " + systemLanguage + "<br />";
- return info;
- }
//浏览器信息
function BrowserInfo() {
var userLanguage = navigator.userLanguage; // 用户在自己的操作系统上设置的语言(火狐没有)
var userAgent = navigator.userAgent; //包含以下属性中所有或一部分的字符串:appCodeName,appName,appVersion,language,platform
var systemLanguage = navigator.systemLanguage; // 用户操作系统支持的默认语言(火狐没有)
var info = "";
info += "浏览器属性信息: " + userAgent + "<br />";
info += "用户设置的操作系统语言: " + userLanguage + "<br />";
info += "操作系统支持的默认语言: " + systemLanguage + "<br />";
return info;
}
2、客户端计算机硬件及系统信息
- //CPU信息
- function CpuInfo() {
- var locator = new ActiveXObject("WbemScripting.SWbemLocator");
- var service = locator.ConnectServer(".");
- var properties = service.ExecQuery("SELECT * FROM Win32_Processor");
- var e = new Enumerator(properties);
- var info = "<table border=1>";
- info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450' >CPU 信息</td></tr>";
- for (; !e.atEnd(); e.moveNext()) {
- var p = e.item();
- info += "<tr style='color: red'><td >CPU序列号:" + p.ProcessorID + "</td></tr>";
- info += "<tr><td >" + p.Caption + "</td></tr>";
- info += "<tr><td >CPU编号:" + p.DeviceID + "</td></tr>";
- info += "<tr><td >CPU型号:" + p.Name + "</td></tr>";
- info += "<tr><td >CPU状态:" + p.CpuStatus + "</td></tr>";
- info += "<tr><td >CPU可用性:" + p.Availability + "</td></tr>";
- info += "<tr><td >CUP Level:" + p.Level + "</td></tr>";
- info += "<tr><td >主机名称:" + p.SystemName + "</td></tr>";
- info += "<tr><td >Processor Type:" + p.ProcessorType + "</td></tr>";
- }
- info += "</table>";
- return info;
- }
- //主板信息
- function MainBoard() {
- var locator = new ActiveXObject("WbemScripting.SWbemLocator");
- var service = locator.ConnectServer(".");
- var properties = service.ExecQuery("SELECT * FROM Win32_BaseBoard");
- var e = new Enumerator(properties);
- var info = "<table border=1>";
- info += "<tr bgcolor='#CDEDED' style='font-weight: bold;'><td width='450'>主板信息 </td></tr>";
- for (; !e.atEnd(); e.moveNext()) {
- var p = e.item();
- info += "<tr style='color: red'><td >主板ID:" + p.SerialNumber + "</td></tr>";
- info += "<tr><td >" + p.HostingBoard + "</td></tr>";
- info += "<tr><td >制造商:" + p.Manufacturer + "</td></tr>";
- info += "<tr><td >是否开启:" + p.PoweredOn + "</td></tr>";
- info += "<tr><td >型号:" + p.Product + "</td></tr>";
- info += "<tr><td >版本:" + p.Version + "</td></tr>";
- }
- info += "</table>";
- return info;
- }
- //Ram信息
- function RamInfo(){
- var locator = new ActiveXObject("WbemScripting.SWbemLocator");
- var service = locator.ConnectServer(".");
- var system=new Enumerator (service.ExecQuery("SELECT * FROM Win32_ComputerSystem")).item();
- var physicMenCap=Math.ceil(system.TotalPhysicalMemory/1024/1024);
- //内存信息
- var memory = new Enumerator (service.ExecQuery("SELECT * FROM Win32_PhysicalMemory"));
- for (var mem = [], i = 0; !memory.atEnd(); memory.moveNext()) {
- mem[i++] = { cap: memory.item().Capacity / 1024 / 1024, speed: memory.item().Speed };
- }
- }
- //网络连接信息
- function IpInfo(){
- var locator = new ActiveXObject("WbemScripting.SWbemLocator");
- var service = locator.ConnectServer(".");
- var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE");
- var e = new Enumerator (properties);
- var info="<table border=1>";
- info+="<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450'>网络连接信息:</td></tr>";
- var i=1;
- for (;!e.atEnd();e.moveNext ()){
- var p = e.item ();
- info+="<tr style='color: red'><td >MAC地址"+i+":" + p.MACAddress + "</td></tr>";
- info+="<tr style='color: red'><td >IP地址"+i+":" + p.IPAddress(0) + "</td></tr>";
- i++;
- }
- info+="</table>";
- return info;
- }
- // 操作系统信息
- function OsInfo() {
- var locator = new ActiveXObject("WbemScripting.SWbemLocator");
- var service = locator.ConnectServer(".");
- var properties = service.ExecQuery("SELECT * FROM Win32_OperatingSystem");
- var e = new Enumerator(properties);
- var info = "<table border=1>";
- info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450'>OS信息:</td></tr>";
- var i = 1;
- for (; !e.atEnd(); e.moveNext()) {
- var p = e.item();
- info += "<tr style='color: red'><td > " + p.BootDevice + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.BuildNumber + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.BuildType + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.Caption + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.CodeSet + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.CountryCode + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.CreationClassName + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.CSCreationClassName + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.CSDVersion + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.CSName + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.CurrentTimeZone + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.DataExecutionPrevention_Available + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.DataExecutionPrevention_32BitApplications + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.DataExecutionPrevention_Drivers + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.DataExecutionPrevention_SupportPolicy + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.Debug + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.Description + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.Distributed + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.EncryptionLevel + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.ForegroundApplicationBoost + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.FreePhysicalMemory + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.FreeSpaceInPagingFiles + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.FreeVirtualMemory + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.InstallDate + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.LargeSystemCache + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.LastBootUpTime + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.LocalDateTime + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.Locale + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.Manufacturer + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.MaxNumberOfProcesses + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.MaxProcessMemorySize + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.Name + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.NumberOfLicensedUsers + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.NumberOfProcesses + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.NumberOfUsers + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.OperatingSystemSKU + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.Organization + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.OSArchitecture + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.OSLanguage + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.OSProductSuite + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.OSType + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.OtherTypeDescription + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.PAEEnabled + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.PlusProductID + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.PlusVersionNumber + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.PortableOperatingSystem + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.Primary + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.ProductType + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.RegisteredUser + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.SerialNumber + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.ServicePackMajorVersion + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.ServicePackMinorVersion + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.SizeStoredInPagingFiles + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.Status + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.SuiteMask + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.SystemDevice + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.SystemDirectory + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.SystemDrive + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.TotalSwapSpaceSize + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.TotalVirtualMemorySize + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.TotalVisibleMemorySize + "</td></tr>";
- info += "<tr style='color: red'><td>" + p.Version + "</td></tr>";
- i++;
- }
- info += "</table>";
- return info;
- }
- //用户帐号信息
- function UidInfo() {
- var locator = new ActiveXObject("WbemScripting.SWbemLocator");
- var service = locator.ConnectServer(".");
- var properties = service.ExecQuery("SELECT * FROM Win32_UserAccount");
- var e = new Enumerator(properties);
- var info = "<table border=1>";
- info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450'>用户帐号信息:</td></tr>";
- var i = 1;
- for (; !e.atEnd(); e.moveNext()) {
- var p = e.item();
- info += "<tr style='color: red'><td > " + i + ":" + p.AccountType + "</td></tr>";
- info += "<tr style='color: red'><td > " + i + ":" + p.Caption + "</td></tr>";
- info += "<tr style='color: red'><td > " + i + ":" + p.Description + "</td></tr>";
- info += "<tr style='color: red'><td > " + i + ":" + p.Disabled + "</td></tr>";
- info += "<tr style='color: red'><td > " + i + ":" + p.Domain + "</td></tr>";
- info += "<tr style='color: red'><td > " + i + ":" + p.FullName + "</td></tr>";
- info += "<tr style='color: red'><td > " + i + ":" + p.InstallDate + "</td></tr>";
- info += "<tr style='color: red'><td > " + i + ":" + p.LocalAccount + "</td></tr>";
- info += "<tr style='color: red'><td > " + i + ":" + p.Lockout + "</td></tr>";
- info += "<tr style='color: red'><td > " + i + ":" + p.Name + "</td></tr>";
- info += "<tr style='color: red'><td > " + i + ":" + p.PasswordChangeable + "</td></tr>";
- info += "<tr style='color: red'><td > " + i + ":" + p.PasswordExpires + "</td></tr>";
- info += "<tr style='color: red'><td > " + i + ":" + p.PasswordRequired + "</td></tr>";
- info += "<tr style='color: red'><td > " + i + ":" + p.SID + "</td></tr>";
- info += "<tr style='color: red'><td > " + i + ":" + p.SIDType + "</td></tr>";
- info += "<tr style='color: red'><td > " + i + ":" + p.Status + "</td></tr>";
- i++;
- }
- info += "</table>";
- return info;
- }
- //系统组帐号信息
- function SysuidInfo() {
- var locator = new ActiveXObject("WbemScripting.SWbemLocator");
- var service = locator.ConnectServer(".");
- var properties = service.ExecQuery("SELECT * FROM Win32_GroupUser");
- var e = new Enumerator(properties);
- var info = "<table border=1>";
- info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td colspan='3'>系统组帐号信息:</td></tr>";
- info += "<tr style='color: red'><td >id</td><td >GroupComponent</td><td >PartComponent</td></tr>";
- var i = 1;
- for (; !e.atEnd(); e.moveNext()) {
- var p = e.item();
- info += "<tr style='color: red'><td > " + i + "</td>";
- info += "<td>" + p.GroupComponent + "</td>";
- info += "<td>" + p.PartComponent + "</td></tr>";
- i++;
- }
- info += "</table>";
- return info;
- }
- //系统管理组信息
- function SysmadInfo() {
- var locator = new ActiveXObject("WbemScripting.SWbemLocator");
- var service = locator.ConnectServer(".");
- var properties = service.ExecQuery("SELECT * FROM Win32_Group");
- var e = new Enumerator(properties);
- var info = "<table border=1>";
- info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td colspan='10'>系统管理组信息:</td></tr>";
- info += "<tr style='color: red'><td >id</td><td >Caption</td><td >Description</td><td >Domain</td><td >InstallDate</td><td >LocalAccount</td><td >Name</td><td >SID</td><td >SIDType</td><td >Status</td></tr>";
- var i = 1;
- for (; !e.atEnd(); e.moveNext()) {
- var p = e.item();
- info += "<tr style='color: red'><td>" + i + "</td>";
- info += "<td>" + p.Caption + "</td>";
- info += "<td>" + p.Description + "</td>";
- info += "<td>" + p.Domain + "</td>";
- info += "<td>" + p.InstallDate + "</td>";
- info += "<td>" + p.LocalAccount + "</td>";
- info += "<td>" + p.Name + "</td>";
- info += "<td>" + p.SID + "</td>";
- info += "<td>" + p.SIDType + "</td>";
- info += "<td>" + p.Status + "</td></tr>";
- i++;
- }
- info += "</table>";
- return info;
- }
- //系统安装的服务信息
- function SysserInfo() {
- var locator = new ActiveXObject("WbemScripting.SWbemLocator");
- var service = locator.ConnectServer(".");
- var properties = service.ExecQuery("SELECT * FROM Win32_Service");
- var e = new Enumerator(properties);
- var info = "<table border=1>";
- info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td colspan='26'>系统安装的服务信息:</td></tr>";
- info += "<tr style='color: red'><td>id</td><td>AcceptPause</td><td>AcceptStop</td><td>Caption</td><td>CheckPoint</td><td>CreationClassName</td><td>Description</td><td>DesktopInteract</td><td>DisplayName</td><td>ErrorControl</td><td>ExitCode</td><td>InstallDate</td><td>Name</td><td>PathName</td><td>ProcessId</td><td>ServiceSpecificExitCode</td><td>ServiceType</td><td>Started</td><td>StartMode</td><td>StartName</td><td>State</td><td>Status</td><td>SystemCreationClassName</td><td>SystemName</td><td>TagId</td><td>WaitHint</td></tr>";
- var i = 1;
- for (; !e.atEnd(); e.moveNext()) {
- var p = e.item();
- info += "<tr style='color: red'><td> " + i + "</td> ";
- info += " <td>" + p.AcceptPause + "</td> ";
- info += " <td>" + p.AcceptStop + "</td> ";
- info += " <td>" + p.Caption + "</td> ";
- info += " <td>" + p.CheckPoint + "</td> ";
- info += " <td>" + p.CreationClassName + "</td> ";
- info += " <td>" + p.Description + "</td> ";
- info += " <td>" + p.DesktopInteract + "</td> ";
- info += " <td>" + p.DisplayName + "</td> ";
- info += " <td>" + p.ErrorControl + "</td> ";
- info += " <td>" + p.ExitCode + "</td> ";
- info += " <td>" + p.InstallDate + "</td> ";
- info += " <td>" + p.Name + "</td> ";
- info += " <td>" + p.PathName + "</td> ";
- info += " <td>" + p.ProcessId + "</td> ";
- info += " <td>" + p.ServiceSpecificExitCode + "</td> ";
- info += " <td>" + p.ServiceType + "</td> ";
- info += " <td>" + p.Started + "</td> ";
- info += " <td>" + p.StartMode + "</td> ";
- info += " <td>" + p.StartName + "</td> ";
- info += " <td>" + p.State + "</td> ";
- info += " <td>" + p.Status + "</td> ";
- info += " <td>" + p.SystemCreationClassName + "</td> ";
- info += " <td>" + p.SystemName + "</td> ";
- info += " <td>" + p.TagId + "</td> ";
- info += " <td>" + p.WaitHint + "</td></tr>";
- i++;
- }
- info += "</table>";
- return info;
- }
//CPU信息
function CpuInfo() {
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_Processor");
var e = new Enumerator(properties);
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450' >CPU 信息</td></tr>";
for (; !e.atEnd(); e.moveNext()) {
var p = e.item();
info += "<tr style='color: red'><td >CPU序列号:" + p.ProcessorID + "</td></tr>";
info += "<tr><td >" + p.Caption + "</td></tr>";
info += "<tr><td >CPU编号:" + p.DeviceID + "</td></tr>";
info += "<tr><td >CPU型号:" + p.Name + "</td></tr>";
info += "<tr><td >CPU状态:" + p.CpuStatus + "</td></tr>";
info += "<tr><td >CPU可用性:" + p.Availability + "</td></tr>";
info += "<tr><td >CUP Level:" + p.Level + "</td></tr>";
info += "<tr><td >主机名称:" + p.SystemName + "</td></tr>";
info += "<tr><td >Processor Type:" + p.ProcessorType + "</td></tr>";
}
info += "</table>";
return info;
} //主板信息
function MainBoard() {
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_BaseBoard");
var e = new Enumerator(properties);
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED' style='font-weight: bold;'><td width='450'>主板信息 </td></tr>";
for (; !e.atEnd(); e.moveNext()) {
var p = e.item();
info += "<tr style='color: red'><td >主板ID:" + p.SerialNumber + "</td></tr>";
info += "<tr><td >" + p.HostingBoard + "</td></tr>";
info += "<tr><td >制造商:" + p.Manufacturer + "</td></tr>";
info += "<tr><td >是否开启:" + p.PoweredOn + "</td></tr>";
info += "<tr><td >型号:" + p.Product + "</td></tr>";
info += "<tr><td >版本:" + p.Version + "</td></tr>";
}
info += "</table>";
return info;
} //Ram信息
function RamInfo(){
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var system=new Enumerator (service.ExecQuery("SELECT * FROM Win32_ComputerSystem")).item();
var physicMenCap=Math.ceil(system.TotalPhysicalMemory/1024/1024);
//内存信息
var memory = new Enumerator (service.ExecQuery("SELECT * FROM Win32_PhysicalMemory"));
for (var mem = [], i = 0; !memory.atEnd(); memory.moveNext()) {
mem[i++] = { cap: memory.item().Capacity / 1024 / 1024, speed: memory.item().Speed };
}
} //网络连接信息
function IpInfo(){
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE");
var e = new Enumerator (properties);
var info="<table border=1>";
info+="<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450'>网络连接信息:</td></tr>";
var i=1;
for (;!e.atEnd();e.moveNext ()){
var p = e.item ();
info+="<tr style='color: red'><td >MAC地址"+i+":" + p.MACAddress + "</td></tr>";
info+="<tr style='color: red'><td >IP地址"+i+":" + p.IPAddress(0) + "</td></tr>";
i++;
}
info+="</table>";
return info;
} // 操作系统信息
function OsInfo() {
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_OperatingSystem");
var e = new Enumerator(properties);
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450'>OS信息:</td></tr>";
var i = 1;
for (; !e.atEnd(); e.moveNext()) {
var p = e.item();
info += "<tr style='color: red'><td > " + p.BootDevice + "</td></tr>";
info += "<tr style='color: red'><td>" + p.BuildNumber + "</td></tr>";
info += "<tr style='color: red'><td>" + p.BuildType + "</td></tr>";
info += "<tr style='color: red'><td>" + p.Caption + "</td></tr>";
info += "<tr style='color: red'><td>" + p.CodeSet + "</td></tr>";
info += "<tr style='color: red'><td>" + p.CountryCode + "</td></tr>";
info += "<tr style='color: red'><td>" + p.CreationClassName + "</td></tr>";
info += "<tr style='color: red'><td>" + p.CSCreationClassName + "</td></tr>";
info += "<tr style='color: red'><td>" + p.CSDVersion + "</td></tr>";
info += "<tr style='color: red'><td>" + p.CSName + "</td></tr>";
info += "<tr style='color: red'><td>" + p.CurrentTimeZone + "</td></tr>";
info += "<tr style='color: red'><td>" + p.DataExecutionPrevention_Available + "</td></tr>";
info += "<tr style='color: red'><td>" + p.DataExecutionPrevention_32BitApplications + "</td></tr>";
info += "<tr style='color: red'><td>" + p.DataExecutionPrevention_Drivers + "</td></tr>";
info += "<tr style='color: red'><td>" + p.DataExecutionPrevention_SupportPolicy + "</td></tr>";
info += "<tr style='color: red'><td>" + p.Debug + "</td></tr>";
info += "<tr style='color: red'><td>" + p.Description + "</td></tr>";
info += "<tr style='color: red'><td>" + p.Distributed + "</td></tr>";
info += "<tr style='color: red'><td>" + p.EncryptionLevel + "</td></tr>";
info += "<tr style='color: red'><td>" + p.ForegroundApplicationBoost + "</td></tr>";
info += "<tr style='color: red'><td>" + p.FreePhysicalMemory + "</td></tr>";
info += "<tr style='color: red'><td>" + p.FreeSpaceInPagingFiles + "</td></tr>";
info += "<tr style='color: red'><td>" + p.FreeVirtualMemory + "</td></tr>";
info += "<tr style='color: red'><td>" + p.InstallDate + "</td></tr>";
info += "<tr style='color: red'><td>" + p.LargeSystemCache + "</td></tr>";
info += "<tr style='color: red'><td>" + p.LastBootUpTime + "</td></tr>";
info += "<tr style='color: red'><td>" + p.LocalDateTime + "</td></tr>";
info += "<tr style='color: red'><td>" + p.Locale + "</td></tr>";
info += "<tr style='color: red'><td>" + p.Manufacturer + "</td></tr>";
info += "<tr style='color: red'><td>" + p.MaxNumberOfProcesses + "</td></tr>";
info += "<tr style='color: red'><td>" + p.MaxProcessMemorySize + "</td></tr>";
info += "<tr style='color: red'><td>" + p.Name + "</td></tr>";
info += "<tr style='color: red'><td>" + p.NumberOfLicensedUsers + "</td></tr>";
info += "<tr style='color: red'><td>" + p.NumberOfProcesses + "</td></tr>";
info += "<tr style='color: red'><td>" + p.NumberOfUsers + "</td></tr>";
info += "<tr style='color: red'><td>" + p.OperatingSystemSKU + "</td></tr>";
info += "<tr style='color: red'><td>" + p.Organization + "</td></tr>";
info += "<tr style='color: red'><td>" + p.OSArchitecture + "</td></tr>";
info += "<tr style='color: red'><td>" + p.OSLanguage + "</td></tr>";
info += "<tr style='color: red'><td>" + p.OSProductSuite + "</td></tr>";
info += "<tr style='color: red'><td>" + p.OSType + "</td></tr>";
info += "<tr style='color: red'><td>" + p.OtherTypeDescription + "</td></tr>";
info += "<tr style='color: red'><td>" + p.PAEEnabled + "</td></tr>";
info += "<tr style='color: red'><td>" + p.PlusProductID + "</td></tr>";
info += "<tr style='color: red'><td>" + p.PlusVersionNumber + "</td></tr>";
info += "<tr style='color: red'><td>" + p.PortableOperatingSystem + "</td></tr>";
info += "<tr style='color: red'><td>" + p.Primary + "</td></tr>";
info += "<tr style='color: red'><td>" + p.ProductType + "</td></tr>";
info += "<tr style='color: red'><td>" + p.RegisteredUser + "</td></tr>";
info += "<tr style='color: red'><td>" + p.SerialNumber + "</td></tr>";
info += "<tr style='color: red'><td>" + p.ServicePackMajorVersion + "</td></tr>";
info += "<tr style='color: red'><td>" + p.ServicePackMinorVersion + "</td></tr>";
info += "<tr style='color: red'><td>" + p.SizeStoredInPagingFiles + "</td></tr>";
info += "<tr style='color: red'><td>" + p.Status + "</td></tr>";
info += "<tr style='color: red'><td>" + p.SuiteMask + "</td></tr>";
info += "<tr style='color: red'><td>" + p.SystemDevice + "</td></tr>";
info += "<tr style='color: red'><td>" + p.SystemDirectory + "</td></tr>";
info += "<tr style='color: red'><td>" + p.SystemDrive + "</td></tr>";
info += "<tr style='color: red'><td>" + p.TotalSwapSpaceSize + "</td></tr>";
info += "<tr style='color: red'><td>" + p.TotalVirtualMemorySize + "</td></tr>";
info += "<tr style='color: red'><td>" + p.TotalVisibleMemorySize + "</td></tr>";
info += "<tr style='color: red'><td>" + p.Version + "</td></tr>";
i++;
}
info += "</table>";
return info;
} //用户帐号信息
function UidInfo() {
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_UserAccount");
var e = new Enumerator(properties);
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450'>用户帐号信息:</td></tr>";
var i = 1;
for (; !e.atEnd(); e.moveNext()) {
var p = e.item(); info += "<tr style='color: red'><td > " + i + ":" + p.AccountType + "</td></tr>";
info += "<tr style='color: red'><td > " + i + ":" + p.Caption + "</td></tr>";
info += "<tr style='color: red'><td > " + i + ":" + p.Description + "</td></tr>";
info += "<tr style='color: red'><td > " + i + ":" + p.Disabled + "</td></tr>";
info += "<tr style='color: red'><td > " + i + ":" + p.Domain + "</td></tr>";
info += "<tr style='color: red'><td > " + i + ":" + p.FullName + "</td></tr>";
info += "<tr style='color: red'><td > " + i + ":" + p.InstallDate + "</td></tr>";
info += "<tr style='color: red'><td > " + i + ":" + p.LocalAccount + "</td></tr>";
info += "<tr style='color: red'><td > " + i + ":" + p.Lockout + "</td></tr>";
info += "<tr style='color: red'><td > " + i + ":" + p.Name + "</td></tr>";
info += "<tr style='color: red'><td > " + i + ":" + p.PasswordChangeable + "</td></tr>";
info += "<tr style='color: red'><td > " + i + ":" + p.PasswordExpires + "</td></tr>";
info += "<tr style='color: red'><td > " + i + ":" + p.PasswordRequired + "</td></tr>";
info += "<tr style='color: red'><td > " + i + ":" + p.SID + "</td></tr>";
info += "<tr style='color: red'><td > " + i + ":" + p.SIDType + "</td></tr>";
info += "<tr style='color: red'><td > " + i + ":" + p.Status + "</td></tr>";
i++;
}
info += "</table>";
return info;
} //系统组帐号信息
function SysuidInfo() {
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_GroupUser");
var e = new Enumerator(properties);
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td colspan='3'>系统组帐号信息:</td></tr>";
info += "<tr style='color: red'><td >id</td><td >GroupComponent</td><td >PartComponent</td></tr>";
var i = 1;
for (; !e.atEnd(); e.moveNext()) {
var p = e.item(); info += "<tr style='color: red'><td > " + i + "</td>";
info += "<td>" + p.GroupComponent + "</td>";
info += "<td>" + p.PartComponent + "</td></tr>";
i++;
}
info += "</table>";
return info;
} //系统管理组信息
function SysmadInfo() {
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_Group");
var e = new Enumerator(properties);
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td colspan='10'>系统管理组信息:</td></tr>";
info += "<tr style='color: red'><td >id</td><td >Caption</td><td >Description</td><td >Domain</td><td >InstallDate</td><td >LocalAccount</td><td >Name</td><td >SID</td><td >SIDType</td><td >Status</td></tr>";
var i = 1;
for (; !e.atEnd(); e.moveNext()) {
var p = e.item(); info += "<tr style='color: red'><td>" + i + "</td>";
info += "<td>" + p.Caption + "</td>";
info += "<td>" + p.Description + "</td>";
info += "<td>" + p.Domain + "</td>";
info += "<td>" + p.InstallDate + "</td>";
info += "<td>" + p.LocalAccount + "</td>";
info += "<td>" + p.Name + "</td>";
info += "<td>" + p.SID + "</td>";
info += "<td>" + p.SIDType + "</td>";
info += "<td>" + p.Status + "</td></tr>";
i++;
}
info += "</table>";
return info;
} //系统安装的服务信息
function SysserInfo() {
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_Service");
var e = new Enumerator(properties);
var info = "<table border=1>";
info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td colspan='26'>系统安装的服务信息:</td></tr>";
info += "<tr style='color: red'><td>id</td><td>AcceptPause</td><td>AcceptStop</td><td>Caption</td><td>CheckPoint</td><td>CreationClassName</td><td>Description</td><td>DesktopInteract</td><td>DisplayName</td><td>ErrorControl</td><td>ExitCode</td><td>InstallDate</td><td>Name</td><td>PathName</td><td>ProcessId</td><td>ServiceSpecificExitCode</td><td>ServiceType</td><td>Started</td><td>StartMode</td><td>StartName</td><td>State</td><td>Status</td><td>SystemCreationClassName</td><td>SystemName</td><td>TagId</td><td>WaitHint</td></tr>";
var i = 1;
for (; !e.atEnd(); e.moveNext()) {
var p = e.item(); info += "<tr style='color: red'><td> " + i + "</td> ";
info += " <td>" + p.AcceptPause + "</td> ";
info += " <td>" + p.AcceptStop + "</td> ";
info += " <td>" + p.Caption + "</td> ";
info += " <td>" + p.CheckPoint + "</td> ";
info += " <td>" + p.CreationClassName + "</td> ";
info += " <td>" + p.Description + "</td> ";
info += " <td>" + p.DesktopInteract + "</td> ";
info += " <td>" + p.DisplayName + "</td> ";
info += " <td>" + p.ErrorControl + "</td> ";
info += " <td>" + p.ExitCode + "</td> ";
info += " <td>" + p.InstallDate + "</td> ";
info += " <td>" + p.Name + "</td> ";
info += " <td>" + p.PathName + "</td> ";
info += " <td>" + p.ProcessId + "</td> ";
info += " <td>" + p.ServiceSpecificExitCode + "</td> ";
info += " <td>" + p.ServiceType + "</td> ";
info += " <td>" + p.Started + "</td> ";
info += " <td>" + p.StartMode + "</td> ";
info += " <td>" + p.StartName + "</td> ";
info += " <td>" + p.State + "</td> ";
info += " <td>" + p.Status + "</td> ";
info += " <td>" + p.SystemCreationClassName + "</td> ";
info += " <td>" + p.SystemName + "</td> ";
info += " <td>" + p.TagId + "</td> ";
info += " <td>" + p.WaitHint + "</td></tr>";
i++;
}
info += "</table>";
return info;
}
代码实现主要包括这几部分:
先通过new ActiveXObject ("WbemScripting.SWbemLocator"); 访问到WbemScripting对象。
通过locator.ConnectServer(".");连接我们本地电脑(.代表本地电脑,当然也可以访问其他计算机)。
通过service.ExecQuery("SELECT * FROM Win32_Processor")这个类似sql的语句(其实系统信息也是存储在计算中一个类似数据库的文件中)获取我们需要的对象的记录 集。
通过new Enumerator来创建一个可枚举的对象,下面就可以遍历取信息了。
注意:运行的前提是要修改浏览器安全设置,“允许对未标记为可安全执行的ActiveX脚本的运行”。
这里主要取了CPU、内存及系统用户几个信息,大家利用WMI的API或者借助JSEDIT获取
到更多的信息。下面列出了常用信息的类:
Win32_Processor // CPU 处理器
Win32_PhysicalMemory // 物理内存
Win32_Keyboard // 键盘
Win32_PointingDevice // 点输入设备,如鼠标
Win32_DiskDrive // 硬盘驱动器
Win32_CDROMDrive // 光盘驱动器
Win32_BaseBoard // 主板
Win32_BIOS // BIOS 芯片
Win32_ParallelPort // 并口
Win32_SerialPort // 串口
Win32_SoundDevice // 多媒体设置
Win32_USBController // USB 控制器
Win32_NetworkAdapter // 网络适配器
Win32_NetworkAdapterConfiguration // 网络适配器设置
Win32_Printer // 打印机
Win32_PrinterConfiguration // 打印机设置
Win32_PrintJob // 打印机任务
Win32_TCPIPPrinterPort // 打印机端口
Win32_POTSModem // MODEM
Win32_POTSModemToSerialPort // MODEM 端口
Win32_DesktopMonitor // 显示器
Win32_VideoController // 显卡细节。
Win32_VideoSettings // 显卡支持的显示模式。
Win32_TimeZone // 时区
Win32_SystemDriver // 驱动程序
Win32_DiskPartition // 磁盘分区
Win32_LogicalDisk // 逻辑磁盘
Win32_LogicalMemoryConfiguration // 逻辑内存配置
Win32_PageFile // 系统页文件信息
Win32_PageFileSetting // 页文件设置
Win32_BootConfiguration // 系统启动配置
Win32_OperatingSystem // 操作系统信息
Win32_StartupCommand // 系统自动启动程序
Win32_Service // 系统安装的服务
Win32_Group // 系统管理组
Win32_GroupUser // 系统组帐号
Win32_UserAccount // 用户帐号
Win32_Process // 系统进程
Win32_Thread // 系统线程
Win32_Share // 共享
Win32_NetworkClient // 已安装的网络客户端
Win32_NetworkProtocol // 已安装的网络协议
WMI Win32类的完整信息及详细列表请参考MSDN:
http://msdn2.microsoft.com/en-us/library/aa394084(VS.85).aspx