Detecting USB Device Connected to Windows PC Using LabVIEW

Updated Jul 20, 2024

This article will explain the method to detect if a certain device is connected to the Windows PC using LabVIEW.
To detect a connected device, you will be utilizing Windows's WMI Command-line utility and execute it using LabVIEW's System Exec VI.

  1. Make sure the connected device is detected in Windows's Device Manager and take note the device description.
  2. Open a blank VI and place the System Exec VI in the block diagram.
  3. Wire an empty string to the command line input terminal and type wmic path CIM_LogicalDevice where "Description like '<device description>'" get name.
  4. Create indicator to the standard output and standard error terminal.
  5. Run the VI. If the device name is detected standard output will return the device name as shown in Device Manager. If the device is not detected, standard error will return No Instance(s) Available.
Below is the example of a finish block diagram.
 
Check Connected Device Arduino.png
This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. 
To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW 
diagram.

In this example we will try to determine if Arduino Uno is connected to the Windows PC using LabVIEW.

 
Get the connected device's device description.
Figure 1: Get the Device description from the device's Properties dialog.

 
CMD Image.png
Figure 2: Results when the command is executed in Windows Command Prompt.

 
LabVIEW Result.png
Figure 3: Result when the specified device is detected (Left) and when the specified device is not connected (Right).