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 ...
随机推荐
- CSS样式一
样式 首先明确: HTML标签也有标签的属性,CSS中的样式也称作为属性,而且某些html中的属性与css中的属性同名,并且作用也相同,但是属于不同的技术. 尺寸样式: 几乎所有的标签有可以设置 wi ...
- 基本排序算法的java实现
本例子实现了一些常见的排序算法,注释中也有一些关于这些算法的思想的描述,这里不做多说,直接上代码. import java.awt.List; import java.util.ArrayList; ...
- javascript-对象的创建(一)
<!DOCTYPE html> <%@ page language="java" contentType="text/html; charset=UTF ...
- java学习笔记_GUI(2)
import javax.swing.*; import java.awt.event.*; class Gui implements ActionListener{ JButton button = ...
- 使用Mybatis Generator 生产 AS400中的数据表对象
第一次使用Mybatis,由于公司核心服务器是AS400,参考了网络各个大大的教程后,发现无法使用Mybatis Generator自动生成AS400中的表对象 参考URL: http://www.c ...
- .net 将excel转成html文件
最近在做一个打印预览功能,但是开始没有头绪后来用excel做了一个模板,然后根据excel模板来生成新的excel并将其存储为html,可以通过http请求在浏览器中读取,并且打印,其他的不多说.方法 ...
- php,javscript调用百地图度API实现标记
最近一个项目需要用到地图的定位和标记功能,本来考虑使用google map API .但是在国内这个速度确实很慢,有时候加载到一半就出现错了,不过可以通过google agent 来解决在国内的访问速 ...
- 【转】用perl写的单位电脑信息采集程序
perl,后来我又改过了增加了一些交互和数据库检测的功能.主要用于收集ip.mac.姓名.房间,后来又加入了维修记录的功能.服务器端接受数据并存入数据库中. 代码如下: 主要用于收集ip.mac.姓名 ...
- 2016022601 - redis入门了解
今天开始学习redis,先从网页上学习,主要学习地址是:易百中的redis和redis中国网站. 此片章学习来自于自:http://www.yiibai.com/redis/redis_quick_g ...
- psutil--跨平台的进程管理
原文地址:http://www.jianshu.com/p/64e265f663f6 Python处理Windows进程 psutil(Python system and process utilit ...