JavaScript hard Drive serial number + Other hardware information _javascript tips

Source: Internet
Author: User
Look at the other data have extracted Cpu,mac ready-made code but no hard disk serial number, looking for a long time to find the parameters of the HDD serial number. So I made up for it.
<title> extract HDD serial number </title>
<script>
function disk () {//hard disk serial number information
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>");
for (;! E.atend (); E.movenext ())
{
var p = e.item ();
document.write ("<tr>");
document.write ("<td>" + p.signature + "</td>");
document.write ("</tr>");
}
document.write ("</table>");
}
</script>
<body>
<input type= "button" value= "Hard drive serial number" onclick= "Disk ()" >
</body>


Find the code here:
For people who have written ASP or. NET, it is very familiar to obtain the hardware information of the client through ASP or. NET language. But how do you get client information through JavaScript, a client script? See the following example:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<title>javascript obtain client hardware information-www.web2bar.cn/</title>
<meta name= "generator" content= Microsoft Visual Studio. NET
7.1 ">
<meta name= "Vs_targetschema"
Content= "HTTP://SCHEMAS.MICROSOFT.COM/INTELLISENSE/IE5" >
<script Id=clienteventhandlersjs language=javascript>
<!--
  
function Button2_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>");
for (;! 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>" + P.processorid + "</td>");
document.write ("<td>" + p.systemname + "</td>");
document.write ("<td>" + P.processortype + "</td>");
document.write ("</tr>");
}
document.write ("</table>");
}
  
function Button1_onclick () {//Floppy information
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = Locator. ConnectServer (".");
var properties = Service. ExecQuery ("SELECT * from win32_floppydrive");
var e = new Enumerator (properties);
document.write ("<table border=1>");
for (;! 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 Button1_onclick () {//cd-rom information
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = Locator. ConnectServer (".");
var properties = Service. ExecQuery ("SELECT * from win32_cdromdrive");
var e = new Enumerator (properties);
document.write ("<table border=1>");
for (;! 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 Button1_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>");
for (;! 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 Button1_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>");
for (;! 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>" + p.serialnumber + "</td>");
document.write ("<td>" + p.version + "</td>");
document.write ("</tr>");
}
document.write ("</table>");
}
  
-->
</script>
<body>
<input id= "Button1" type= "button" value= "button"
Name= "Button1" Language=javascript onclick= "return Button1_onclick ()" >
</body>

The main advantage of using JavaScript to get information from clients is that there is no need for server resources. No need to refresh the page. The script is displayed directly on the client.

The parameters for the hard drive serial number are found here:
\ ' Get the hard drive serial number
Dim Cmicwmi as New System.Management.ManagementObjectSearcher (\ "SELECT * from Win32_diskdrive\")
Dim Uint32 as UInt32
For each cmicwmiobj as ManagementObject in Cmicwmi.get
Uint32 = Cmicwmiobj (\ "Signature\")
Next
TextBox1.Text = uint32.tostring
And in a piece finally to put forward, hehe.
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.