JS obtains client computer hardware information and system information

Source: Internet
Author: User
<HTML> 

Save the preceding Code as an HTML file during use.

WMI is used to obtain the hardware and system information of the Client Computer: 1 // obtain the system information
2 function getsysinfo (){
3 var locator = new activexobject ("wbemscripting. swbemlocator ");
4 var service = locator. connectserver (".");
5 // CPU Information
6 var CPU = new enumerator (service. execquery ("select * From win32_processor"). Item ();
7 var cputype = CPU. Name, hostname = CPU. systemname;
8 // memory information
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 // system information
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}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.