Javascript hard drive serial number + other hardware information

Source: Internet
Author: User

I looked at other materials, including CPU extraction, but there was no hard disk serial number in MAC out-of-the-box code. After searching for a long time, I found the parameter for extracting the hard disk serial number. So I made it up.
<Html>
<Head>
<Title> extract the hard drive serial number </title>
<Script>
Function disk () {// hard disk serial number
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>
</Head>
<Body>
<Input type = "button" value = "hard disk serial number" onclick = "disk ()">
</Body>
</Html>

The 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:
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<Html>
<Head>
<Title> javascript obtains 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 disk 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>
</Head>
<Body>
<INPUT id = "Button1" type = "button" value = "Button"
Name = "Button1" language = javascript onclick = "return Button1_onclick ()">
</Body>
</Html>
The main advantage of using javascript to obtain client information is that you do not need server resources, you do not need to refresh the webpage, And you can directly execute scripts on the client for display.

The hard disk serial number parameter is found here:
\ 'Obtain the hard disk 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 finally proposed in one piece, huh, huh.

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.