USB device information using WMI


The System.Management namespace of the .NET framework has some Windows-specific features for recovering information regarding a USB device. The following list of WMI (Windows Management Instrumentation) classes are enough to recover almost all information one could need regarding the device:

The FriendlyName attribute is common to all of these classes and can be used to filter for a specific device. This is how one can query for a specific USB device if you have a product and vendor ID for it:

  ManagementObjectSearcher searcher = new ManagementObjectSearcher(
    "SELECT PNPDeviceID, Name, Service FROM Win32_PnPEntity WHERE PNPDeviceID LIKE "
    + "'%VID[_]xxxx&PID[_]xxxx%'");

  foreach (ManagementObject entity in searcher.Get())
  {
    // do something useful
  }

The Service field can be used to determine which system driver is being used, or filter results based on it. These are some values the field can assume:

  • BthPan – Bluetooth PAN (personal area network) profile device.
  • usb_rndisx – USB RNDIS device.

Kudos to Emerson de Lira Espinola for discovering this.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s