I downloaded the WMI Code Creator and used it to get c# code for 'Win32_PnPEntity' using the name property.
In WMI Code creator lets you search for the property values for the name property and I did get a list for the USB device, however when I copied the code and put it in my program, it does not list the device that I want.
Both programs obviously run on the same OS and so I don't understand why it wont list the device in my program. The code below is what I extracted from WMI CC.
using System;
using System.Management;
using System.Windows.Forms;
namespace WMISample
{
public class MyWMIQuery
{
public static void Main()
{
try
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_PnPEntity");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("Win32_PnPEntity instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("Name: {0}", queryObj["Name"]);
}
}
catch (ManagementException e)
{
MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
}
}
}
}
Any ideas what this could be?