Search code examples
c#windows-10wmiwindowsiot

get keyboardfilter WMI parameters in c#


On Windows IoT (but also on the normal Windows 10), you can enable keyboard filter and shell launcher. I enabled UWF, KB-Filter and Shell Launcher.

Now, I can't get the parameters of my keyboardfilter with a simple C#.NET program.

ManagementScope scope = new ManagementScope(@"root\standardcimv2\embedded");
using (ManagementClass mc = new ManagementClass(scope.Path.Path, "WEKF_Settings", null))
{
    ManagementObjectCollection moc = mc.GetInstances();
    foreach (ManagementObject mo in moc)
    {
    }
}

The UWF_Filter is working. WEKF_Settings and WESL_UserSetting are not working, even if they are enabled on the OS.

I get always the exception Provider Load Failure, even if the application is started as administrator.

In powershell, I get the class without any problem:

Get-CimClass wekf_settings \\.\root\standardcimv2\embedded | select -expand cimclassqualifiers

So the question: why can't I get the instances (with GetInstances()) in C# but only with powershell?


Solution

  • Just as info (if you get the same error):
    The query fails also on Powershell, if this is 32-bit.

    You need to compile the program as 64bit. Then the code will be able to query the keyboard filter.

    This was the solution.