# Identifying specific USB devices

**URL:** <https://forum.xojo.com/t/identifying-specific-usb-devices/64999>\
**Category:** Windows\
**Created:** [August 11, 2021, 5:48pm UTC](https://forum.xojo.com/t/identifying-specific-usb-devices/64999 "2021-08-11T17:48:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thom\_McGrath](https://forum.xojo.com/user_avatar/forum.xojo.com/thom_mcgrath/32/192_2.png) [@Thom\_McGrath](https://forum.xojo.com/u/Thom_McGrath)\
**Post date:** [August 11, 2021, 5:48pm UTC](https://forum.xojo.com/t/identifying-specific-usb-devices/64999/1 "2021-08-11T17:48:38Z")

</div>

I have the vendor id and product id of a specific usb device I’m looking to open a serial connection to. I know the device will support the connection. What I need to do is create a list of only the paths for this particular class of device. There could be more than one of the same device connected.

The current code just does

```xojo
Var DeviceBound As Integer = SerialDevice.Count - 1
For Idx As Integer = 0 To DeviceBound
  Var Device As SerialDevice = SerialDevice.At(Idx)
  // Do stuff
Next Idx

```

But this of course shows me all devices without a way for me to determine which of them are for the device I’m looking for. On Mac this has been solved with IORegistry. On Windows, I don’t really know where to begin. MBS plugins are an option. Anybody have any ideas?

---

<div class="post-metadata">

**Author:** ![anon20074439](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@anon20074439](https://forum.xojo.com/u/anon20074439)\
**Post date:** [August 13, 2021, 6:06pm UTC](https://forum.xojo.com/t/identifying-specific-usb-devices/64999/2 "2021-08-13T18:06:22Z")

</div>

I just dug my barcode scanner out and threw this together, let me know if you don’t want to go via a shell and powershall and I’ll see what I can do, it returns COM5 in a string which you can use with your code above.

```auto
Dim sh As New shell
sh.TimeOut = -1
sh.ExecuteMode = shell.ExecuteModes.Synchronous
sh.Execute("powershell (Get-WmiObject -Class Win32_SerialPort -Filter \""PNPDeviceID='USB\\VID_080C&PID_0400\\S/N_E10D05648'\"").DeviceID")
system.DebugLog(sh.Result)

```

---

<div class="post-metadata">

**Author:** ![Thom\_McGrath](https://forum.xojo.com/user_avatar/forum.xojo.com/thom_mcgrath/32/192_2.png) [@Thom\_McGrath](https://forum.xojo.com/u/Thom_McGrath)\
**Post date:** [August 13, 2021, 6:31pm UTC](https://forum.xojo.com/t/identifying-specific-usb-devices/64999/3 "2021-08-13T18:31:01Z")

</div>

Yeah unfortunately, as far as I’m aware, PowerShell isn’t generally available enough. Thank you though.

---

<div class="post-metadata">

**Author:** ![anon20074439](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@anon20074439](https://forum.xojo.com/u/anon20074439)\
**Post date:** [August 13, 2021, 6:38pm UTC](https://forum.xojo.com/t/identifying-specific-usb-devices/64999/4 "2021-08-13T18:38:24Z")

</div>

Then there’s wmic, but you’ll need to cut the com port out of the ()'s

```auto
wmic path win32_pnpentity where PNPDeviceID="USB\\VID_080C&PID_0400\\S/N_E10D05648" get Name /format:csv

```

or the registry (not 100% on this one as I just did a registry search for the vendor id and found it, not read into it much, seems like a cache of assigned ports)

```auto
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\COM Name Arbiter\Devices

```

---

<div class="post-metadata">

**Author:** ![brian\_franco](https://forum.xojo.com/user_avatar/forum.xojo.com/brian_franco/32/156_2.png) [@brian\_franco](https://forum.xojo.com/u/brian_franco)\
**Post date:** [August 13, 2021, 6:40pm UTC](https://forum.xojo.com/t/identifying-specific-usb-devices/64999/5 "2021-08-13T18:40:55Z")

</div>

Just a note that future wmic may run into problems

> **[Windows 10 features we’re no longer developing - Windows Deployment](https://docs.microsoft.com/en-us/windows/deployment/planning/windows-10-deprecated-features)**
>
> Review the list of features that are no longer being developed in Windows 10

---

<div class="post-metadata">

**Author:** ![anon20074439](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@anon20074439](https://forum.xojo.com/u/anon20074439)\
**Post date:** [August 13, 2021, 6:42pm UTC](https://forum.xojo.com/t/identifying-specific-usb-devices/64999/6 "2021-08-13T18:42:06Z")

</div>

Ah ok, powershell is the replacement then, good to know, thanks Brian
