2
Good afternoon,
I have the code below in VBA that returns me the USB ports in use. However I need to know which one is sending me the data from the bar code reader, because I will use 8 readers in a single computer. Thus it is necessary to define from which reader the script is receiving the information.
Dim strComputer As String
Dim strDeviceName As String
Dim objWMIService As Object
Dim colControllers As Object
Dim objController As Object
Dim colUSBDevices As Object
Dim objUSBDevice As Object
If TextBox2.Value = "" Then
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colControllers = objWMIService.ExecQuery("Select * From Win32_USBControllerDevice")
For Each objController In colControllers
strDeviceName = Replace(objController.Dependent, Chr(34), "")
strDeviceName = Right(strDeviceName, Len(strDeviceName) - WorksheetFunction.Find("=", strDeviceName))
Set colUSBDevices = objWMIService.ExecQuery("Select * From Win32_PnPEntity Where DeviceID = '" & strDeviceName & "'")
For Each objUSBDevice In colUSBDevices
If objUSBDevice.DeviceID = "HID\VID_0C2E&PID_0B41&MI_00\7&33B8233E&0&0000" Then
end if