JavaScript 获取客户端计算机硬件及系统信息
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
JavaScript 获取客户端计算机硬件及系统信息的更多相关文章
- JavaScript获取客户端计算机硬件及系统等信息的方法
JavaScript获取客户端计算机硬件及系统等信息的方法 JavaScript 获取客户端计算机硬件及系统信息 通过WMI来实现获取客户端计算机硬件及系统信息: function getSysInf ...
- js获取客户端计算机硬件及系统信息
注意:(1):遇到“automation服务器不能创建对象”的问题 解决方案: 1.在“运行”中执行regsvr32 scrrun.dll 2.安全模式设置成“中”,如果javascript脚本中报这 ...
- javascript获取客户端默认打印机
JS <script language="javascript"> function startRequest() { var oShell = new ActiveX ...
- JavaScript获取客户端IP地址
1. 第三方接口 1) 这里提供一个搜狐接口的地址:http://pv.sohu.com/cityjson?ie=utf-8 ,将这个js引入到页面即可得到returnCitySN. 2) api.i ...
- Javascript 获取客户端的运营商 IP 地址 等
客户端获取运营商 会弹出安全隐患问题,需要修改IE activx 选项, 非常麻烦,用我的代码可以轻松获取. <script src="JS/jquery-1.4.1.js" ...
- JS获取客户端IP地址、MAC和主机名七种方法
一.使用JS获取客户端IP的几个方法方法一(只针对IE且客户端的IE允许AcitiveX运行,通过平台:XP,SERVER03,2000).获取客户端IP代码:<HTML><HEAD ...
- JS获取客户端IP地址、MAC和主机名【转】
JS获取客户端IP地址.MAC和主机名 引用:JS获取客户端IP地址.MAC和主机名的7个方法汇总 利用搜狐接口 <html> <head> <meta http-equ ...
- JS获取客户端IP地址、MAC和主机名的7个方法汇总
今天在搞JS(javascript)获取客户端IP的小程序,上网搜了下,好多在现在的系统和浏览器中的都无效,很无奈,在Chrome.FireFox中很少搞到直接利用ActiveX获取IP等的JS脚本. ...
- js 获取客户端mac地址
js 获取客户端mac地址 javascript获取客户端网卡MAC地址和IP地址和计算机名 nodesj如何获得客户端的mac地址呢? 浏览器获取MAC地址 不限浏览器的mac地址取得的几种办法 I ...
随机推荐
- makefile--编译出现,未定义的字符
ld: 0711-317 ERROR: Undefined symbol: .CEntityManager::SetParameter(CString,CString,SColumnInfo) /// ...
- JetBRAINS 系列注册机
转载说明 本篇文章可能已经更新,最新文章请转:http://www.sollyu.com/1118/ 说明 这个是一国外的大牛写的一个 JetBRAINS 系列注册机,他里面包含了很多,我就不打字了. ...
- Science论文"Clustering by fast search and find of density peaks"学习笔记
"Clustering by fast search and find of density peaks"是今年6月份在<Science>期刊上发表的的一篇论文,论文中 ...
- HotSpot算法实现
1.枚举根节点 可作为GC Roots的节点主要在全局性的引用(例如常量或类静态属性)与执行上下文(例如栈帧中的本地变量表)中. 可达性分析对执行时间的敏感体现在GC停顿上,因为分析工作必须在能确保一 ...
- C++中执行windows指令
执行windows指令: BOOL ExecDosCmd(]) { SECURITY_ATTRIBUTES sa; HANDLE hRead,hWrite; sa.nLength = sizeof(S ...
- 2014-10 u-boot make过程分析
/** ****************************************************************************** * @author Maox ...
- 伪元素content的应用
日常开发中,我们常用:before,:after来实现一些效果,比如 – 边框 – 图标 此时的content中只是为了伪元素能渲染出来而声明 1 2 3 div:before{ content: & ...
- net发布mvc项目
1.复制 Web 文件夹 2.复制 DLL 文件C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies C ...
- 《C和指针》读书笔记——第五章 操作符和表达式
1.当/操作符的两个操作数都是整数时,它执行整除运算:其他都是执行浮点数除法. 2.逻辑移位:左边移入的位用0填充: 算数移位:左边移入的位用符号位填充: 3.位置1 :value |= 1<& ...
- 使用saltstack批量部署服务器运行环境事例——批量部署nagios客户端
之前关于搭建web服务器集群实验的这篇文章http://www.cnblogs.com/cjyfff/p/3553579.html中,关于如何用saltstack批量部署服务器这一点当时没有记录到文章 ...