JavaScript to obtain hardware information

Source: Internet
Author: User

From csdn

// I looked at other materials for extraction of CPU, but the Mac's ready-made code did not have the hard disk serial number. After searching for a long time, I found the parameter for extracting the hard disk serial number. So I made it up. <SCRIPT> function disk () {// var locator = new activexobject ("wbemscripting. swbemlocator "); var service = locator. connectserver (". "); var properties = service. execquery ("select * From win32_diskdrive"); var E = new enumerator (properties); document. write ("<Table border = 1>"); document. write ("<caption> hard disk serial number </caption>"); (;! E. atend (); E. movenext () {var P = E. item (); document. write ("<tr>"); document. write ("<TD style = 'color: Blue'>" + P. signature + "</TD>"); document. write ("</tr>");} document. write ("</table>");} disk (); </SCRIPT>
// Code found here: // for ASP or. net users, through ASP or. net Language to obtain client hardware information is very familiar. // but how can I obtain client information through a client script such as JavaScript? See the following example:
<SCRIPT> function button1_onclick () {// CPU information var locator = new activexobject ("wbemscripting. swbemlocator "); var service = locator. connectserver (". "); var properties = service. execquery ("select * From win32_processor"); var E = new enumerator (properties); document. write ("<Table border = 1>"); document. write ("<caption> CPU Information </caption>"); (;! E. atend (); E. movenext () {var P = E. item (); document. write ("<tr>"); document. write ("<TD>" + P. caption + "</TD>"); document. write ("<TD>" + P. deviceID + "</TD>"); document. write ("<TD>" + P. name + "</TD>"); document. write ("<TD>" + P. cpustatus + "</TD>"); document. write ("<TD>" + P. availability + "</TD>"); document. write ("<TD>" + P. LEVEL + "</TD>"); document. write ("<TD style = 'color: Blue'>" + P. process OrId + "</TD>"); document. write ("<TD>" + P. systemname + "</TD>"); document. write ("<TD>" + P. processortype + "</TD>"); document. write ("</tr>");} document. write ("</table>");} function button2_onclick () {// floppy disk information var locator = new activexobject ("wbemscripting. swbemlocator "); var service = locator. connectserver (". "); var properties = service. execquery ("select * From win32_floppydrive"); var E = new E Numerator (properties); document. Write ("<Table border = 1>"); document. Write ("<caption> floppy disk Information </caption>"); (;! E. atend (); E. movenext () {var P = E. item (); document. write ("<tr>"); document. write ("<TD>" + P. description + "</TD>"); document. write ("<TD>" + P. deviceID + "</TD>"); document. write ("<TD>" + P. status + "</TD>"); document. write ("<TD>" + P. manufacuturer + "</TD>"); document. write ("</tr>");} document. write ("</table>");} function button3_onclick () {// CD-ROM information var locator = new activexobject ("wbemsc Ripting. swbemlocator "); var service = locator. connectserver (". "); var properties = service. execquery ("select * From win32_cdromdrive"); var E = new enumerator (properties); document. write ("<Table border = 1>"); document. write ("<caption> CD-ROM Information </caption>"); (;! E. atend (); E. movenext () {var P = E. item (); document. write ("<tr>"); document. write ("<TD>" + P. caption + "</TD>"); document. write ("<TD>" + P. description + "</TD>"); document. write ("<TD>" + P. drive + "</TD>"); document. write ("<TD>" + P. status + "</TD>"); document. write ("<TD>" + P. medialoaded + "</TD>"); document. write ("</tr>");} document. write ("</table>");} function button4_onclick () {// keyboard information VaR Locator = new activexobject ("wbemscripting. swbemlocator "); var service = locator. connectserver (". "); var properties = service. execquery ("select * From win32_keyboard"); var E = new enumerator (properties); document. write ("<Table border = 1>"); document. write ("<caption> keyboard Information </caption>"); (;! E. atend (); E. movenext () {var P = E. item (); document. write ("<tr>"); document. write ("<TD>" + P. description + "</TD>"); document. write ("<TD>" + P. name + "</TD>"); document. write ("<TD>" + P. status + "</TD>"); document. write ("</tr>");} document. write ("</table>");} function button5_onclick () {// motherboard information var locator = new activexobject ("wbemscripting. swbemlocator "); var service = locator. connectserver (". "); Var properties = service. execquery ("select * From win32_baseboard"); var E = new enumerator (properties); document. write ("<Table border = 1>"); document. write ("<caption> motherboard Information </caption>"); (;! E. atend (); E. movenext () {var P = E. item (); document. write ("<tr>"); document. write ("<TD>" + P. hostingboard + "</TD>"); document. write ("<TD>" + P. manufacturer + "</TD>"); document. write ("<TD>" + P. poweredon + "</TD>"); document. write ("<TD>" + P. product + "</TD>"); document. write ("<TD style = 'color: Blue'>" + P. serialnumber + "</TD>"); document. write ("<TD>" + P. version + "</TD>"); document. write ("</tr>");} document. write ("</table>") ;}button%onclick (); button2_onclick (); button3_onclick (); button4_onclick (); button5_onclick (); </SCRIPT>

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.