Imports System.Management Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim fso As Object Dim dc As Object Dim d As Object Dim xx As String fso = CreateObject("Scripting.FileSystemObject") dc = fso.Drives For Each d In dc xx = d.DriveLetter Next Me.TextBox2.Text = GetSerialNumber(xx & ":") End Sub Public Function GetSerialNumber(ByVal DriveLetter As String) As String DriveLetter = Mid$(DriveLetter, 1, 2) If Mid$(DriveLetter, 2, 1) <> ":" Then Return "" Dim wmi_ld, wmi_dp, wmi_dd As ManagementObject Dim temp, parts(), ans As String ans = "" ' get the Logical Disk for that drive letter wmi_ld = New ManagementObject("Win32_LogicalDisk.DeviceID='" & _ DriveLetter.TrimEnd("\"c) & "'") ' get the associated DiskPartition For Each wmi_dp In wmi_ld.GetRelated("Win32_DiskPartition") ' get the associated DiskDrive For Each wmi_dd In wmi_dp.GetRelated("Win32_DiskDrive") ' There is a bug in WinVista that corrupts some of the fields ' of the Win32_DiskDrive class if you instantiate the class via ' its primary key (as in the example above) and the device is ' a USB disk. Oh well... so we have go thru this extra step Dim wmi As New ManagementClass("Win32_DiskDrive") ' loop thru all of the instances. This is silly, we shouldn't ' have to loop thru them all, when we know which one we want. For Each obj As ManagementObject In wmi.GetInstances ' do the DeviceID fields match? If obj("DeviceID").ToString = wmi_dd("DeviceID").ToString Then ' the serial number is embedded in the PnPDeviceID temp = obj("PnPDeviceID").ToString If Not temp.StartsWith("USBSTOR") Then MessageBox.Show(DriveLetter & " doesn't appear to be USB Device", "Error") Return "" End If parts = temp.Split("\&".ToCharArray) ' The serial number should be the next to the last element ans = parts(parts.Length - 2) End If Next Next Next Return ans End Function End Class