Good evening, I have a small challenge that I'm trying to get around. I have a user environment where all devices are 'built' using identical system images and identical hardware. It's a small point of sale environment. The software on the computers requires devices to be connected to particular USB other wise the devices will not work with the software. This presents a lot of issues as the cables aren't physically labelled.
I'm trying to create a small Visual Basic application which is able to check what device is connected to each USB port on the system. The program seems simple to me, but I've been having difficulty with the code for a few days. Is it possible to return the USB Port ID using the code below. I'm able to retrieve then DeviceID, but I now need to compare this with the USB ID to confirm it's in the correct port, how can I retrieve the USB Port ID/Name?
Dim sc As New ManagementScope("\\DESKTOP-BA9EEM9\root\cimv2")
Dim query As New ObjectQuery("Select * from Win32_USBHub")
Dim searcher As New ManagementObjectSearcher(sc, query)
Dim result As ManagementObjectCollection = searcher.Get()
For Each obj As ManagementObject In result
If obj("Description") IsNot Nothing Then
ListBox1.Items.Add("Description:" & vbTab + obj("Description").ToString())
End If
If obj("DeviceID") IsNot Nothing Then
ListBox1.Items.Add("DeviceID:" & vbTab + obj("DeviceID").ToString())
End If
If obj("PNPDeviceID") IsNot Nothing Then
ListBox1.Items.Add("PNPDeviceID:" & vbTab + obj("PNPDeviceID").ToString())
End If
ListBox1.Items.Add("----------------------------------------")