Dim diskArray As String()
Dim driveNumber As String
Dim searcher As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_LogicalDiskToPartition")
For Each dm As System.Management.ManagementObject In searcher.Get()
Dim inValue As String = dm("Antecedent").ToString()
Dim posFoundStart = inValue.IndexOf("""")
Dim posFoundEnd = inValue.IndexOf("""", posFoundStart + 1)
Dim parsedValue = inValue.Substring(posFoundStart + 1, (posFoundEnd - posFoundStart) - 1)
diskArray = parsedValue.Split(","c)
driveNumber = diskArray(0).Remove(0, 6).Trim()
Dim disks = New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
For Each disk As System.Management.ManagementObject In disks.[Get]()
If disk("Name").ToString() = ("\\.\PHYSICALDRIVE" & driveNumber) And disk("InterfaceType").ToString() = "USB" Then
Dim deviceId As String = disk("PNPDeviceID").ToString()
Dim splitDeviceId = deviceId.Split("\"c)
Dim arrayLen = splitDeviceId.Length - 1
Dim serialArray = splitDeviceId(arrayLen).Split("&"c)
Dim serial = serialArray(0)
Output.Show(serial)
End If
Next
Next