Can anyone tell me how to get USB serial number(Hardware ID) using VB.net?
Asked
Active
Viewed 1.0k times
3
-
1Very unclear, I assume you mean the USB device. They don't have serial numbers, only a Vendor and Product ID. Used by plug & play, it is always the same for the same device from the same manufacturer. – Hans Passant Sep 19 '10 at 12:52
1 Answers
-1
You should use WMI for this, specifically querying the Win32_USBController Class. The property you want to get is DeviceID.'
A sample WMI call in the context of a console application might look like this:
Dim mos As New ManagementObjectSearcher("SELECT * FROM Win32_UsbController")
For Each mo As ManagementObject In mos.Get()
Console.WriteLine(mo.Properties.Item("DeviceID").Value)
Next
Console.ReadLine()
You would need to add references to System.Management
and System.Management.Instrumentation
to use ManagementObjectSearcher and ManagementObject.

Den
- 16,686
- 4
- 47
- 87
-
I tried your code, but its showing error: Type 'managementObjectSearcher' is not defined Type 'managementObject' is not defined – Phoenix Sep 19 '10 at 04:36
-
-
1I seriously doubt the OP wants this. The controller properties are always the same on the same machine. – Hans Passant Sep 19 '10 at 12:50
-
The problem is - to go deeper to get to the manufacturer's ID the OP would either need an SDK from that manufacturer or develop a lower-level library that could do that. WMI goes as far as providing the IDs outlined in the post. – Den Sep 19 '10 at 16:39