LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

js获取客户端计算机硬件信息与系统信息(只支持IE)

admin
2014年11月24日 23:16 本文热度 5909



 


  1. <html>

  2. <head>


  3. <script>

  4. var info = allinfo();

  5. document.write(info);


  6. var locator = new ActiveXObject ("WbemScripting.SWbemLocator");

  7. var service = locator.ConnectServer(".");

  8. info = pcInfo();


  9. document.write(info);


  10. //获取浏览器相关信息

  11. function allinfo(){

  12. var userLanguage = navigator.userLanguage; // 用户在自己的操作系统上设置的语言(火狐没有)

  13. var userAgent = navigator.userAgent; //包含以下属性中所有或一部分的字符串:appCodeName,appName,appVersion,language,platform

  14. var systemLanguage = navigator.systemLanguage; // 用户操作系统支持的默认语言(火狐没有)




  15. info+="浏览器属性信息: "+userAgent+"<br />";

  16. info+="用户设置的操作系统语言: "+userLanguage+"<br />";

  17. info+="操作系统支持的默认语言: "+systemLanguage+"<br />";

  18. return info;

  19. }


  20. /******************************************以上为浏览器信息,以下为pc信息************************************************/



  21. function cpuInfo() {//CPU 信息

  22. var properties = service.ExecQuery("SELECT * FROM Win32_Processor");

  23. var e = new Enumerator (properties);

  24. var info = "<table border=1>";

  25. info+="<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450' >CPU 信息</td></tr>";

  26. for (;!e.atEnd();e.moveNext ()) {

  27. var p = e.item ();

  28. info+="<tr style='color: red'><td >CPU序列号:" + p.ProcessorID + "</td></tr>";

  29. info+="<tr><td >"+p.Caption+"</td></tr>";

  30. info+="<tr><td >CPU编号:"+p.DeviceID+"</td></tr>";

  31. info+="<tr><td >CPU型号:" + p.Name + "</td></tr>";

  32. info+="<tr><td >CPU状态:" + p.CpuStatus + "</td></tr>";

  33. info+="<tr><td >CPU可用性:" + p.Availability + "</td></tr>";

  34. info+="<tr><td >CUP Level:" + p.Level + "</td></tr>";

  35. info+="<tr><td >主机名称:" + p.SystemName + "</td></tr>";

  36. info+="<tr><td >Processor Type:" + p.ProcessorType + "</td></tr>";

  37. }

  38. info+="</table>";

  39. return info;

  40. }

  41. function mainBoard() {//主板信息

  42. var properties = service.ExecQuery("SELECT * FROM Win32_BaseBoard");

  43. var e = new Enumerator (properties);

  44. var info="<table border=1>";

  45. info+="<tr bgcolor='#CDEDED' style='font-weight: bold;'><td width='450'>主板信息 </td></tr>";

  46. for (;!e.atEnd();e.moveNext ()) {

  47. var p = e.item ();

  48. info+="<tr style='color: red'><td >主板ID:" + p.SerialNumber + "</td></tr>";

  49. info+="<tr><td >" + p.HostingBoard + "</td></tr>";

  50. info+="<tr><td >制造商:" + p.Manufacturer + "</td></tr>";

  51. info+="<tr><td >是否开启:" + p.PoweredOn + "</td></tr>";

  52. info+="<tr><td >型号:" + p.Product + "</td></tr>";

  53. info+="<tr><td >版本:" + p.Version + "</td></tr>";

  54. }

  55. info+="</table>";

  56. return info;

  57. }

  58. //获取Ram信息

  59. function raminfo(){

  60. var system=new Enumerator (service.ExecQuery("SELECT * FROM Win32_ComputerSystem")).item();


  61. var physicMenCap=Math.ceil(system.TotalPhysicalMemory/1024/1024);

  62. //内存信息

  63. var memory = new Enumerator (service.ExecQuery("SELECT * FROM Win32_PhysicalMemory"));

  64. for (var mem=[],i=0;!memory.atEnd();memory.moveNext()){

  65. mem[i++]={cap:memory.item().Capacity/1024/1024,speed:memory.item().Speed};

  66. }

  67. var info="<table border=1>";

  68. info+="<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450'>内存信息 </td></tr>";

  69. info+="<tr style='color: red'><td >内存总量:";

  70. memDX = 0;

  71. for(var mi=0;mi<mem.length;mi++){

  72. memDX += mem[mi].cap;

  73. }

  74. info+= memDX + "M</td></tr>";

  75. info+="<tr style='color: red'><td >可用物理内存:" +physicMenCap + "M</td></tr>";

  76. info+="</table>";

  77. return info;

  78. }

  79. //获取网络连接信息

  80. function ipinfo(){

  81. var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE");

  82. var e = new Enumerator (properties);

  83. var info="<table border=1>";

  84. info+="<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450'>网络连接信息:</td></tr>";

  85. var i=1;

  86. for (;!e.atEnd();e.moveNext ()){

  87. var p = e.item ();

  88. info+="<tr style='color: red'><td >MAC地址"+i+":" + p.MACAddress + "</td></tr>";

  89. info+="<tr style='color: red'><td >IP地址"+i+":" + p.IPAddress(0) + "</td></tr>";

  90. i++;

  91. }

  92. info+="</table>";

  93. return info;

  94. }

  95. // 获取操作系统信息

  96. function osinfo(){

  97. var properties = service.ExecQuery("SELECT * FROM Win32_OperatingSystem");

  98. var e = new Enumerator (properties);

  99. var info="<table border=1>";

  100. info+="<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450'>OS信息:</td></tr>";

  101. var i=1;

  102. for (;!e.atEnd();e.moveNext ()){

  103. var p = e.item ();

  104. info+="<tr style='color: red'><td > " + p.BootDevice + "</td></tr>";

  105. info+="<tr style='color: red'><td>" + p.BuildNumber + "</td></tr>";

  106. info+="<tr style='color: red'><td>" + p.BuildType + "</td></tr>";

  107. info+="<tr style='color: red'><td>" + p.Caption + "</td></tr>";

  108. info+="<tr style='color: red'><td>" + p.CodeSet + "</td></tr>";

  109. info+="<tr style='color: red'><td>" + p.CountryCode + "</td></tr>";

  110. info+="<tr style='color: red'><td>" + p.CreationClassName + "</td></tr>";

  111. info+="<tr style='color: red'><td>" + p.CSCreationClassName + "</td></tr>";

  112. info+="<tr style='color: red'><td>" + p.CSDVersion + "</td></tr>";

  113. info+="<tr style='color: red'><td>" + p.CSName + "</td></tr>";

  114. info+="<tr style='color: red'><td>" + p.CurrentTimeZone + "</td></tr>";

  115. info+="<tr style='color: red'><td>" + p.DataExecutionPrevention_Available + "</td></tr>";

  116. info+="<tr style='color: red'><td>" + p.DataExecutionPrevention_32BitApplications + "</td></tr>";

  117. info+="<tr style='color: red'><td>" + p.DataExecutionPrevention_Drivers + "</td></tr>";

  118. info+="<tr style='color: red'><td>" + p.DataExecutionPrevention_SupportPolicy + "</td></tr>";

  119. info+="<tr style='color: red'><td>" + p.Debug + "</td></tr>";

  120. info+="<tr style='color: red'><td>" + p.Description + "</td></tr>";

  121. info+="<tr style='color: red'><td>" + p.Distributed + "</td></tr>";

  122. info+="<tr style='color: red'><td>" + p.EncryptionLevel + "</td></tr>";

  123. info+="<tr style='color: red'><td>" + p.ForegroundApplicationBoost + "</td></tr>";

  124. info+="<tr style='color: red'><td>" + p.FreePhysicalMemory + "</td></tr>";

  125. info+="<tr style='color: red'><td>" + p.FreeSpaceInPagingFiles + "</td></tr>";

  126. info+="<tr style='color: red'><td>" + p.FreeVirtualMemory + "</td></tr>";

  127. info+="<tr style='color: red'><td>" + p.InstallDate + "</td></tr>";

  128. info+="<tr style='color: red'><td>" + p.LargeSystemCache + "</td></tr>";

  129. info+="<tr style='color: red'><td>" + p.LastBootUpTime + "</td></tr>";

  130. info+="<tr style='color: red'><td>" + p.LocalDateTime + "</td></tr>";

  131. info+="<tr style='color: red'><td>" + p.Locale + "</td></tr>";

  132. info+="<tr style='color: red'><td>" + p.Manufacturer + "</td></tr>";

  133. info+="<tr style='color: red'><td>" + p.MaxNumberOfProcesses + "</td></tr>";

  134. info+="<tr style='color: red'><td>" + p.MaxProcessMemorySize + "</td></tr>";

  135. info+="<tr style='color: red'><td>" + p.Name + "</td></tr>";

  136. info+="<tr style='color: red'><td>" + p.NumberOfLicensedUsers + "</td></tr>";

  137. info+="<tr style='color: red'><td>" + p.NumberOfProcesses + "</td></tr>";

  138. info+="<tr style='color: red'><td>" + p.NumberOfUsers + "</td></tr>";

  139. info+="<tr style='color: red'><td>" + p.OperatingSystemSKU + "</td></tr>";

  140. info+="<tr style='color: red'><td>" + p.Organization + "</td></tr>";

  141. info+="<tr style='color: red'><td>" + p.OSArchitecture + "</td></tr>";

  142. info+="<tr style='color: red'><td>" + p.OSLanguage + "</td></tr>";

  143. info+="<tr style='color: red'><td>" + p.OSProductSuite + "</td></tr>";

  144. info+="<tr style='color: red'><td>" + p.OSType + "</td></tr>";

  145. info+="<tr style='color: red'><td>" + p.OtherTypeDescription + "</td></tr>";

  146. info+="<tr style='color: red'><td>" + p.PAEEnabled + "</td></tr>";

  147. info+="<tr style='color: red'><td>" + p.PlusProductID + "</td></tr>";

  148. info+="<tr style='color: red'><td>" + p.PlusVersionNumber + "</td></tr>";

  149. info+="<tr style='color: red'><td>" + p.PortableOperatingSystem + "</td></tr>";

  150. info+="<tr style='color: red'><td>" + p.Primary + "</td></tr>";

  151. info+="<tr style='color: red'><td>" + p.ProductType + "</td></tr>";

  152. info+="<tr style='color: red'><td>" + p.RegisteredUser + "</td></tr>";

  153. info+="<tr style='color: red'><td>" + p.SerialNumber + "</td></tr>";

  154. info+="<tr style='color: red'><td>" + p.ServicePackMajorVersion + "</td></tr>";

  155. info+="<tr style='color: red'><td>" + p.ServicePackMinorVersion + "</td></tr>";

  156. info+="<tr style='color: red'><td>" + p.SizeStoredInPagingFiles + "</td></tr>";

  157. info+="<tr style='color: red'><td>" + p.Status + "</td></tr>";

  158. info+="<tr style='color: red'><td>" + p.SuiteMask + "</td></tr>";

  159. info+="<tr style='color: red'><td>" + p.SystemDevice + "</td></tr>";

  160. info+="<tr style='color: red'><td>" + p.SystemDirectory + "</td></tr>";

  161. info+="<tr style='color: red'><td>" + p.SystemDrive + "</td></tr>";

  162. info+="<tr style='color: red'><td>" + p.TotalSwapSpaceSize + "</td></tr>";

  163. info+="<tr style='color: red'><td>" + p.TotalVirtualMemorySize + "</td></tr>";

  164. info+="<tr style='color: red'><td>" + p.TotalVisibleMemorySize + "</td></tr>";

  165. info+="<tr style='color: red'><td>" + p.Version + "</td></tr>";

  166. //info+="<tr style='color: red'><td>" + p.MUILanguages[] + "</td></tr>";

  167. i++;

  168. }

  169. info+="</table>";

  170. return info;

  171. }

  172. //获取用户帐号信息

  173. function uidinfo(){

  174. var properties = service.ExecQuery("SELECT * FROM Win32_UserAccount");

  175. var e = new Enumerator (properties);

  176. var info="<table border=1>";

  177. info+="<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td width='450'>用户帐号信息:</td></tr>";

  178. var i=1;

  179. for (;!e.atEnd();e.moveNext ()){

  180. var p = e.item ();


  181. info+="<tr style='color: red'><td > " + i + ":" + p.AccountType + "</td></tr>";

  182. info+="<tr style='color: red'><td > " + i + ":" + p.Caption + "</td></tr>";

  183. info+="<tr style='color: red'><td > " + i + ":" + p.Description + "</td></tr>";

  184. info+="<tr style='color: red'><td > " + i + ":" + p.Disabled + "</td></tr>";

  185. info+="<tr style='color: red'><td > " + i + ":" + p.Domain + "</td></tr>";

  186. info+="<tr style='color: red'><td > " + i + ":" + p.FullName + "</td></tr>";

  187. info+="<tr style='color: red'><td > " + i + ":" + p.InstallDate + "</td></tr>";

  188. info+="<tr style='color: red'><td > " + i + ":" + p.LocalAccount + "</td></tr>";

  189. info+="<tr style='color: red'><td > " + i + ":" + p.Lockout + "</td></tr>";

  190. info+="<tr style='color: red'><td > " + i + ":" + p.Name + "</td></tr>";

  191. info+="<tr style='color: red'><td > " + i + ":" + p.PasswordChangeable + "</td></tr>";

  192. info+="<tr style='color: red'><td > " + i + ":" + p.PasswordExpires + "</td></tr>";

  193. info+="<tr style='color: red'><td > " + i + ":" + p.PasswordRequired + "</td></tr>";

  194. info+="<tr style='color: red'><td > " + i + ":" + p.SID + "</td></tr>";

  195. info+="<tr style='color: red'><td > " + i + ":" + p.SIDType + "</td></tr>";

  196. info+="<tr style='color: red'><td > " + i + ":" + p.Status + "</td></tr>";

  197. i++;

  198. }

  199. info+="</table>";

  200. return info;

  201. }

  202. //获取系统组帐号信息

  203. function sysuidinfo(){

  204. var properties = service.ExecQuery("SELECT * FROM Win32_GroupUser");

  205. var e = new Enumerator (properties);

  206. var info="<table border=1>";

  207. info+="<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td colspan='3'>系统组帐号信息:</td></tr>";

  208. info+="<tr style='color: red'><td >id</td><td >GroupComponent</td><td >PartComponent</td></tr>";

  209. var i=1;

  210. for (;!e.atEnd();e.moveNext ()){

  211. var p = e.item ();


  212. info+="<tr style='color: red'><td > " + i + "</td>";

  213. info+="<td>" + p.GroupComponent + "</td>";

  214. info+="<td>" + p.PartComponent + "</td></tr>";

  215. i++;

  216. }

  217. info+="</table>";

  218. return info;

  219. }

  220. //获取系统管理组信息

  221. function sysmadinfo(){

  222. var properties = service.ExecQuery("SELECT * FROM Win32_Group");

  223. var e = new Enumerator (properties);

  224. var info="<table border=1>";

  225. info+="<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td colspan='10'>系统管理组信息:</td></tr>";

  226. 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>";

  227. var i=1;

  228. for (;!e.atEnd();e.moveNext ()){

  229. var p = e.item ();


  230. info+="<tr style='color: red'><td>" + i + "</td>";

  231. info+="<td>" + p.Caption + "</td>";

  232. info+="<td>" + p.Description + "</td>";

  233. info+="<td>" + p.Domain + "</td>";

  234. info+="<td>" + p.InstallDate + "</td>";

  235. info+="<td>" + p.LocalAccount + "</td>";

  236. info+="<td>" + p.Name + "</td>";

  237. info+="<td>" + p.SID + "</td>";

  238. info+="<td>" + p.SIDType + "</td>";

  239. info+="<td>" + p.Status + "</td></tr>";

  240. i++;

  241. }

  242. info+="</table>";

  243. return info;

  244. }

  245. //获取系统安装的服务信息

  246. function sysserinfo(){

  247. var properties = service.ExecQuery("SELECT * FROM Win32_Service");

  248. var e = new Enumerator (properties);

  249. var info="<table border=1>";

  250. info+="<tr bgcolor='#CDEDED' style='font-weight: bold;' ><td colspan='26'>系统安装的服务信息:</td></tr>";

  251. 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>";

  252. var i=1;

  253. for (;!e.atEnd();e.moveNext ()){

  254. var p = e.item ();


  255. info+="<tr style='color: red'><td> " + i + "</td> ";

  256. info+=" <td>" + p.AcceptPause + "</td> ";

  257. info+=" <td>" + p.AcceptStop + "</td> ";

  258. info+=" <td>" + p.Caption + "</td> ";

  259. info+=" <td>" + p.CheckPoint + "</td> ";

  260. info+=" <td>" + p.CreationClassName + "</td> ";

  261. info+=" <td>" + p.Description + "</td> ";

  262. info+=" <td>" + p.DesktopInteract + "</td> ";

  263. info+=" <td>" + p.DisplayName + "</td> ";

  264. info+=" <td>" + p.ErrorControl + "</td> ";

  265. info+=" <td>" + p.ExitCode + "</td> ";

  266. info+=" <td>" + p.InstallDate + "</td> ";

  267. info+=" <td>" + p.Name + "</td> ";

  268. info+=" <td>" + p.PathName + "</td> ";

  269. info+=" <td>" + p.ProcessId + "</td> ";

  270. info+=" <td>" + p.ServiceSpecificExitCode + "</td> ";

  271. info+=" <td>" + p.ServiceType + "</td> ";

  272. info+=" <td>" + p.Started + "</td> ";

  273. info+=" <td>" + p.StartMode + "</td> ";

  274. info+=" <td>" + p.StartName + "</td> ";

  275. info+=" <td>" + p.State + "</td> ";

  276. info+=" <td>" + p.Status + "</td> ";

  277. info+=" <td>" + p.SystemCreationClassName + "</td> ";

  278. info+=" <td>" + p.SystemName + "</td> ";

  279. info+=" <td>" + p.TagId + "</td> ";

  280. info+=" <td>" + p.WaitHint + "</td></tr>";

  281. i++;

  282. }

  283. info+="</table>";

  284. return info;

  285. }




  286. /*

  287. fnShowPrcName("Win32_StartupCommand") // 系统自动启动程序

  288. */


  289. function pcInfo() { //所有信息

  290. var info=cpuInfo();

  291. info+=raminfo();

  292. info+=mainBoard();

  293. info+=ipinfo();

  294. info+=osinfo();

  295. info+=uidinfo();

  296. info+=sysuidinfo();

  297. info+=sysmadinfo();

  298. info+=sysserinfo();


  299. return info;

  300. }

  301. </script>

  302. </head>

  303. <body>

  304. <div id="elInfo" >

  305. </div>

  306. </body>

  307. </html>


使用时把以上代码保存为html文件,支持IE浏览器

通过WMI来实现获取客户端计算机硬件及系统信息:

1//系统信息获取
2function getSysInfo(){
3 var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
4 var service = locator.ConnectServer(".");
5 //CPU信息
6 var cpu = new Enumerator (service.ExecQuery("SELECT * FROM Win32_Processor")).item();
7 var cpuType=cpu.Name,hostName=cpu.SystemName;
8 //内存信息
9 var memory = new Enumerator (service.ExecQuery("SELECT * FROM Win32_PhysicalMemory"));
10 for (var mem=[],i=0; !memory.atEnd(); memory.moveNext()) mem[i++]={cap:memory.item().Capacity/1024/1024,speed:memory.item().Speed}
11 //系统信息
12 var system=new Enumerator (service.ExecQuery("SELECT * FROM Win32_ComputerSystem")).item();
13 var physicMenCap=Math.ceil(system.TotalPhysicalMemory/1024/1024),curUser=system.UserName,cpuCount=system.NumberOfProcessors
14
15 return {cpuType:cpuType,cpuCount:cpuCount,hostName:hostName,curUser:curUser,memCap:physicMenCap,mem:mem}
16}

该文章在 2014/11/24 23:16:45 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved