Check for yellow bangs in Device Manager

188 Views Asked by At

I need to find the number of devices (on Windows 11) with yellow bangs.

I found this WQL query:

SELECT * FROM Win32_PnPEntity WHERE ConfigManagerErrorCode <> 0

I implemented this in Python. It does return devices with bangs, but it also returns devices that were manually disabled. Here's one:

instance of Win32_PnPEntity
{
        Caption = "58200";
        CompatibleID = {"USB\\Class_FE&SubClass_00&Prot_00", "USB\\Class_FE&SubClass_00", "USB\\Class_FE"};
        ConfigManagerErrorCode = 28;
        ConfigManagerUserConfig = FALSE;
        CreationClassName = "Win32_PnPEntity";
        Description = "58200";
        DeviceID = "USB\\VID_0A5C&PID_5843\\0123456789ABCD";
        HardwareID = {"USB\\VID_0A5C&PID_5843&REV_0102", "USB\\VID_0A5C&PID_5843"};
        Name = "58200";
        PNPDeviceID = "USB\\VID_0A5C&PID_5843\\0123456789ABCD";
        Present = TRUE;
        Status = "Error";
        SystemCreationClassName = "Win32_ComputerSystem";
        SystemName = "mySystem";
};

All the fields, including Status and ConfigManagerErrorCode, are identical whether it's banged or disabled by the user.

Is there a way to differentiate between the two device states? All I need in the end is whether the number of devices with bangs is greater than zero, but not including manually disabled devices - preferably with Python, C++ or PowerShell.

0

There are 0 best solutions below