I using WMI in order to get all drivers in system:
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("SELECT * FROM Win32_PnPSignedDriver");
foreach (ManagementObject WmiObject in searcher.Get())
{
Console.WriteLine("{0,-35} {1,-40}", "ClassGuid", WmiObject["ClassGuid"]);// String
Console.WriteLine("{0,-35} {1,-40}", "DeviceClass", WmiObject["DeviceClass"]);// String
Console.WriteLine("{0,-35} {1,-40}", "DeviceID", WmiObject["DeviceID"]);// String
Console.WriteLine("{0,-35} {1,-40}", "DeviceName", WmiObject["DeviceName"]);// String
Console.WriteLine("{0,-35} {1,-40}", "Manufacturer", WmiObject["Manufacturer"]);// String
Console.WriteLine("{0,-35} {1,-40}", "Name", WmiObject["Name"]);// String
Console.WriteLine("{0,-35} {1,-40}", "Status", WmiObject["Status"]);// String
}
For some reason, 'Status' is always null. I running as Administrator on Windows 10.
Any ideas what I doing wrong?
I think your approach is wrong. Why do you want to go to
Win32_PnPSignedDriver
? You can achieve more if you check out theWin32_SystemDriver
, which will return you the state, status and started as you wish. Use the following class example, to get the information you need:btw, with this object, you can start,stop,pause drivers