JavaScript 获取客户端计算机硬件及系统信息

1、浏览器信息

  1. //浏览器信息
  2. function BrowserInfo() {
  3. var userLanguage = navigator.userLanguage;     // 用户在自己的操作系统上设置的语言(火狐没有)
  4. var userAgent = navigator.userAgent;           //包含以下属性中所有或一部分的字符串:appCodeName,appName,appVersion,language,platform
  5. var systemLanguage = navigator.systemLanguage; // 用户操作系统支持的默认语言(火狐没有)
  6. var info = "";
  7. info += "浏览器属性信息: " + userAgent + "<br />";
  8. info += "用户设置的操作系统语言: " + userLanguage + "<br />";
  9. info += "操作系统支持的默认语言: " + systemLanguage + "<br />";
  10. return info;
  11. }
//浏览器信息
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、客户端计算机硬件及系统信息

  1. //CPU信息
  2. function CpuInfo() {
  3. var locator = new ActiveXObject("WbemScripting.SWbemLocator");
  4. var service = locator.ConnectServer(".");
  5. var properties = service.ExecQuery("SELECT * FROM Win32_Processor");
  6. var e = new Enumerator(properties);
  7. var info = "<table border=1>";
  8. info += "<tr  bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450' >CPU 信息</td></tr>";
  9. for (; !e.atEnd(); e.moveNext()) {
  10. var p = e.item();
  11. info += "<tr style='color: red'><td >CPU序列号:" + p.ProcessorID + "</td></tr>";
  12. info += "<tr><td >" + p.Caption + "</td></tr>";
  13. info += "<tr><td >CPU编号:" + p.DeviceID + "</td></tr>";
  14. info += "<tr><td >CPU型号:" + p.Name + "</td></tr>";
  15. info += "<tr><td >CPU状态:" + p.CpuStatus + "</td></tr>";
  16. info += "<tr><td >CPU可用性:" + p.Availability + "</td></tr>";
  17. info += "<tr><td >CUP Level:" + p.Level + "</td></tr>";
  18. info += "<tr><td >主机名称:" + p.SystemName + "</td></tr>";
  19. info += "<tr><td >Processor Type:" + p.ProcessorType + "</td></tr>";
  20. }
  21. info += "</table>";
  22. return info;
  23. }
  24. //主板信息
  25. function MainBoard() {
  26. var locator = new ActiveXObject("WbemScripting.SWbemLocator");
  27. var service = locator.ConnectServer(".");
  28. var properties = service.ExecQuery("SELECT * FROM Win32_BaseBoard");
  29. var e = new Enumerator(properties);
  30. var info = "<table border=1>";
  31. info += "<tr bgcolor='#CDEDED' style='font-weight: bold;'><td width='450'>主板信息 </td></tr>";
  32. for (; !e.atEnd(); e.moveNext()) {
  33. var p = e.item();
  34. info += "<tr style='color: red'><td >主板ID:" + p.SerialNumber + "</td></tr>";
  35. info += "<tr><td >" + p.HostingBoard + "</td></tr>";
  36. info += "<tr><td >制造商:" + p.Manufacturer + "</td></tr>";
  37. info += "<tr><td >是否开启:" + p.PoweredOn + "</td></tr>";
  38. info += "<tr><td >型号:" + p.Product + "</td></tr>";
  39. info += "<tr><td >版本:" + p.Version + "</td></tr>";
  40. }
  41. info += "</table>";
  42. return info;
  43. }
  44. //Ram信息
  45. function RamInfo(){
  46. var locator = new ActiveXObject("WbemScripting.SWbemLocator");
  47. var service = locator.ConnectServer(".");
  48. var system=new Enumerator (service.ExecQuery("SELECT * FROM Win32_ComputerSystem")).item();
  49. var physicMenCap=Math.ceil(system.TotalPhysicalMemory/1024/1024);
  50. //内存信息
  51. var memory = new Enumerator (service.ExecQuery("SELECT * FROM Win32_PhysicalMemory"));
  52. for (var mem = [], i = 0; !memory.atEnd(); memory.moveNext()) {
  53. mem[i++] = { cap: memory.item().Capacity / 1024 / 1024, speed: memory.item().Speed };
  54. }
  55. }
  56. //网络连接信息
  57. function IpInfo(){
  58. var locator = new ActiveXObject("WbemScripting.SWbemLocator");
  59. var service = locator.ConnectServer(".");
  60. var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE");
  61. var e = new Enumerator (properties);
  62. var info="<table border=1>";
  63. info+="<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450'>网络连接信息:</td></tr>";
  64. var i=1;
  65. for (;!e.atEnd();e.moveNext ()){
  66. var p = e.item ();
  67. info+="<tr style='color: red'><td >MAC地址"+i+":" + p.MACAddress + "</td></tr>";
  68. info+="<tr style='color: red'><td >IP地址"+i+":" + p.IPAddress(0) + "</td></tr>";
  69. i++;
  70. }
  71. info+="</table>";
  72. return info;
  73. }
  74. // 操作系统信息
  75. function OsInfo() {
  76. var locator = new ActiveXObject("WbemScripting.SWbemLocator");
  77. var service = locator.ConnectServer(".");
  78. var properties = service.ExecQuery("SELECT * FROM Win32_OperatingSystem");
  79. var e = new Enumerator(properties);
  80. var info = "<table border=1>";
  81. info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450'>OS信息:</td></tr>";
  82. var i = 1;
  83. for (; !e.atEnd(); e.moveNext()) {
  84. var p = e.item();
  85. info += "<tr style='color: red'><td > " + p.BootDevice + "</td></tr>";
  86. info += "<tr style='color: red'><td>" + p.BuildNumber + "</td></tr>";
  87. info += "<tr style='color: red'><td>" + p.BuildType + "</td></tr>";
  88. info += "<tr style='color: red'><td>" + p.Caption + "</td></tr>";
  89. info += "<tr style='color: red'><td>" + p.CodeSet + "</td></tr>";
  90. info += "<tr style='color: red'><td>" + p.CountryCode + "</td></tr>";
  91. info += "<tr style='color: red'><td>" + p.CreationClassName + "</td></tr>";
  92. info += "<tr style='color: red'><td>" + p.CSCreationClassName + "</td></tr>";
  93. info += "<tr style='color: red'><td>" + p.CSDVersion + "</td></tr>";
  94. info += "<tr style='color: red'><td>" + p.CSName + "</td></tr>";
  95. info += "<tr style='color: red'><td>" + p.CurrentTimeZone + "</td></tr>";
  96. info += "<tr style='color: red'><td>" + p.DataExecutionPrevention_Available + "</td></tr>";
  97. info += "<tr style='color: red'><td>" + p.DataExecutionPrevention_32BitApplications + "</td></tr>";
  98. info += "<tr style='color: red'><td>" + p.DataExecutionPrevention_Drivers + "</td></tr>";
  99. info += "<tr style='color: red'><td>" + p.DataExecutionPrevention_SupportPolicy + "</td></tr>";
  100. info += "<tr style='color: red'><td>" + p.Debug + "</td></tr>";
  101. info += "<tr style='color: red'><td>" + p.Description + "</td></tr>";
  102. info += "<tr style='color: red'><td>" + p.Distributed + "</td></tr>";
  103. info += "<tr style='color: red'><td>" + p.EncryptionLevel + "</td></tr>";
  104. info += "<tr style='color: red'><td>" + p.ForegroundApplicationBoost + "</td></tr>";
  105. info += "<tr style='color: red'><td>" + p.FreePhysicalMemory + "</td></tr>";
  106. info += "<tr style='color: red'><td>" + p.FreeSpaceInPagingFiles + "</td></tr>";
  107. info += "<tr style='color: red'><td>" + p.FreeVirtualMemory + "</td></tr>";
  108. info += "<tr style='color: red'><td>" + p.InstallDate + "</td></tr>";
  109. info += "<tr style='color: red'><td>" + p.LargeSystemCache + "</td></tr>";
  110. info += "<tr style='color: red'><td>" + p.LastBootUpTime + "</td></tr>";
  111. info += "<tr style='color: red'><td>" + p.LocalDateTime + "</td></tr>";
  112. info += "<tr style='color: red'><td>" + p.Locale + "</td></tr>";
  113. info += "<tr style='color: red'><td>" + p.Manufacturer + "</td></tr>";
  114. info += "<tr style='color: red'><td>" + p.MaxNumberOfProcesses + "</td></tr>";
  115. info += "<tr style='color: red'><td>" + p.MaxProcessMemorySize + "</td></tr>";
  116. info += "<tr style='color: red'><td>" + p.Name + "</td></tr>";
  117. info += "<tr style='color: red'><td>" + p.NumberOfLicensedUsers + "</td></tr>";
  118. info += "<tr style='color: red'><td>" + p.NumberOfProcesses + "</td></tr>";
  119. info += "<tr style='color: red'><td>" + p.NumberOfUsers + "</td></tr>";
  120. info += "<tr style='color: red'><td>" + p.OperatingSystemSKU + "</td></tr>";
  121. info += "<tr style='color: red'><td>" + p.Organization + "</td></tr>";
  122. info += "<tr style='color: red'><td>" + p.OSArchitecture + "</td></tr>";
  123. info += "<tr style='color: red'><td>" + p.OSLanguage + "</td></tr>";
  124. info += "<tr style='color: red'><td>" + p.OSProductSuite + "</td></tr>";
  125. info += "<tr style='color: red'><td>" + p.OSType + "</td></tr>";
  126. info += "<tr style='color: red'><td>" + p.OtherTypeDescription + "</td></tr>";
  127. info += "<tr style='color: red'><td>" + p.PAEEnabled + "</td></tr>";
  128. info += "<tr style='color: red'><td>" + p.PlusProductID + "</td></tr>";
  129. info += "<tr style='color: red'><td>" + p.PlusVersionNumber + "</td></tr>";
  130. info += "<tr style='color: red'><td>" + p.PortableOperatingSystem + "</td></tr>";
  131. info += "<tr style='color: red'><td>" + p.Primary + "</td></tr>";
  132. info += "<tr style='color: red'><td>" + p.ProductType + "</td></tr>";
  133. info += "<tr style='color: red'><td>" + p.RegisteredUser + "</td></tr>";
  134. info += "<tr style='color: red'><td>" + p.SerialNumber + "</td></tr>";
  135. info += "<tr style='color: red'><td>" + p.ServicePackMajorVersion + "</td></tr>";
  136. info += "<tr style='color: red'><td>" + p.ServicePackMinorVersion + "</td></tr>";
  137. info += "<tr style='color: red'><td>" + p.SizeStoredInPagingFiles + "</td></tr>";
  138. info += "<tr style='color: red'><td>" + p.Status + "</td></tr>";
  139. info += "<tr style='color: red'><td>" + p.SuiteMask + "</td></tr>";
  140. info += "<tr style='color: red'><td>" + p.SystemDevice + "</td></tr>";
  141. info += "<tr style='color: red'><td>" + p.SystemDirectory + "</td></tr>";
  142. info += "<tr style='color: red'><td>" + p.SystemDrive + "</td></tr>";
  143. info += "<tr style='color: red'><td>" + p.TotalSwapSpaceSize + "</td></tr>";
  144. info += "<tr style='color: red'><td>" + p.TotalVirtualMemorySize + "</td></tr>";
  145. info += "<tr style='color: red'><td>" + p.TotalVisibleMemorySize + "</td></tr>";
  146. info += "<tr style='color: red'><td>" + p.Version + "</td></tr>";
  147. i++;
  148. }
  149. info += "</table>";
  150. return info;
  151. }
  152. //用户帐号信息
  153. function UidInfo() {
  154. var locator = new ActiveXObject("WbemScripting.SWbemLocator");
  155. var service = locator.ConnectServer(".");
  156. var properties = service.ExecQuery("SELECT * FROM Win32_UserAccount");
  157. var e = new Enumerator(properties);
  158. var info = "<table border=1>";
  159. info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450'>用户帐号信息:</td></tr>";
  160. var i = 1;
  161. for (; !e.atEnd(); e.moveNext()) {
  162. var p = e.item();
  163. info += "<tr style='color: red'><td > " + i + ":" + p.AccountType + "</td></tr>";
  164. info += "<tr style='color: red'><td > " + i + ":" + p.Caption + "</td></tr>";
  165. info += "<tr style='color: red'><td > " + i + ":" + p.Description + "</td></tr>";
  166. info += "<tr style='color: red'><td > " + i + ":" + p.Disabled + "</td></tr>";
  167. info += "<tr style='color: red'><td > " + i + ":" + p.Domain + "</td></tr>";
  168. info += "<tr style='color: red'><td > " + i + ":" + p.FullName + "</td></tr>";
  169. info += "<tr style='color: red'><td > " + i + ":" + p.InstallDate + "</td></tr>";
  170. info += "<tr style='color: red'><td > " + i + ":" + p.LocalAccount + "</td></tr>";
  171. info += "<tr style='color: red'><td > " + i + ":" + p.Lockout + "</td></tr>";
  172. info += "<tr style='color: red'><td > " + i + ":" + p.Name + "</td></tr>";
  173. info += "<tr style='color: red'><td > " + i + ":" + p.PasswordChangeable + "</td></tr>";
  174. info += "<tr style='color: red'><td > " + i + ":" + p.PasswordExpires + "</td></tr>";
  175. info += "<tr style='color: red'><td > " + i + ":" + p.PasswordRequired + "</td></tr>";
  176. info += "<tr style='color: red'><td > " + i + ":" + p.SID + "</td></tr>";
  177. info += "<tr style='color: red'><td > " + i + ":" + p.SIDType + "</td></tr>";
  178. info += "<tr style='color: red'><td > " + i + ":" + p.Status + "</td></tr>";
  179. i++;
  180. }
  181. info += "</table>";
  182. return info;
  183. }
  184. //系统组帐号信息
  185. function SysuidInfo() {
  186. var locator = new ActiveXObject("WbemScripting.SWbemLocator");
  187. var service = locator.ConnectServer(".");
  188. var properties = service.ExecQuery("SELECT * FROM Win32_GroupUser");
  189. var e = new Enumerator(properties);
  190. var info = "<table border=1>";
  191. info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td colspan='3'>系统组帐号信息:</td></tr>";
  192. info += "<tr style='color: red'><td >id</td><td >GroupComponent</td><td >PartComponent</td></tr>";
  193. var i = 1;
  194. for (; !e.atEnd(); e.moveNext()) {
  195. var p = e.item();
  196. info += "<tr style='color: red'><td > " + i + "</td>";
  197. info += "<td>" + p.GroupComponent + "</td>";
  198. info += "<td>" + p.PartComponent + "</td></tr>";
  199. i++;
  200. }
  201. info += "</table>";
  202. return info;
  203. }
  204. //系统管理组信息
  205. function SysmadInfo() {
  206. var locator = new ActiveXObject("WbemScripting.SWbemLocator");
  207. var service = locator.ConnectServer(".");
  208. var properties = service.ExecQuery("SELECT * FROM Win32_Group");
  209. var e = new Enumerator(properties);
  210. var info = "<table border=1>";
  211. info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td colspan='10'>系统管理组信息:</td></tr>";
  212. 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>";
  213. var i = 1;
  214. for (; !e.atEnd(); e.moveNext()) {
  215. var p = e.item();
  216. info += "<tr style='color: red'><td>" + i + "</td>";
  217. info += "<td>" + p.Caption + "</td>";
  218. info += "<td>" + p.Description + "</td>";
  219. info += "<td>" + p.Domain + "</td>";
  220. info += "<td>" + p.InstallDate + "</td>";
  221. info += "<td>" + p.LocalAccount + "</td>";
  222. info += "<td>" + p.Name + "</td>";
  223. info += "<td>" + p.SID + "</td>";
  224. info += "<td>" + p.SIDType + "</td>";
  225. info += "<td>" + p.Status + "</td></tr>";
  226. i++;
  227. }
  228. info += "</table>";
  229. return info;
  230. }
  231. //系统安装的服务信息
  232. function SysserInfo() {
  233. var locator = new ActiveXObject("WbemScripting.SWbemLocator");
  234. var service = locator.ConnectServer(".");
  235. var properties = service.ExecQuery("SELECT * FROM Win32_Service");
  236. var e = new Enumerator(properties);
  237. var info = "<table border=1>";
  238. info += "<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td colspan='26'>系统安装的服务信息:</td></tr>";
  239. 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>";
  240. var i = 1;
  241. for (; !e.atEnd(); e.moveNext()) {
  242. var p = e.item();
  243. info += "<tr style='color: red'><td> " + i + "</td> ";
  244. info += " <td>" + p.AcceptPause + "</td> ";
  245. info += " <td>" + p.AcceptStop + "</td> ";
  246. info += " <td>" + p.Caption + "</td> ";
  247. info += " <td>" + p.CheckPoint + "</td> ";
  248. info += " <td>" + p.CreationClassName + "</td> ";
  249. info += " <td>" + p.Description + "</td> ";
  250. info += " <td>" + p.DesktopInteract + "</td> ";
  251. info += " <td>" + p.DisplayName + "</td> ";
  252. info += " <td>" + p.ErrorControl + "</td> ";
  253. info += " <td>" + p.ExitCode + "</td> ";
  254. info += " <td>" + p.InstallDate + "</td> ";
  255. info += " <td>" + p.Name + "</td> ";
  256. info += " <td>" + p.PathName + "</td> ";
  257. info += " <td>" + p.ProcessId + "</td> ";
  258. info += " <td>" + p.ServiceSpecificExitCode + "</td> ";
  259. info += " <td>" + p.ServiceType + "</td> ";
  260. info += " <td>" + p.Started + "</td> ";
  261. info += " <td>" + p.StartMode + "</td> ";
  262. info += " <td>" + p.StartName + "</td> ";
  263. info += " <td>" + p.State + "</td> ";
  264. info += " <td>" + p.Status + "</td> ";
  265. info += " <td>" + p.SystemCreationClassName + "</td> ";
  266. info += " <td>" + p.SystemName + "</td> ";
  267. info += " <td>" + p.TagId + "</td> ";
  268. info += " <td>" + p.WaitHint + "</td></tr>";
  269. i++;
  270. }
  271. info += "</table>";
  272. return info;
  273. }
//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

上一篇:LeetCode H-Index II


下一篇:solr特点六: DIH (从数据源导入数据)