Forum Discussion
ManniX-ITA
Sep 30, 2021Copper Contributor
Windows 11 WHEA ErrorSource control via WMI is broken
The WMI call to disable a WHEA ErrorSource is broken in Windows 11 while it works properly on Windows 10.
https://docs.microsoft.com/en-us/windows-hardware/drivers/whea/disabling-an-error-source
The Sources accept the command and are changing status to Stopped but they still log errors as if they aren't stopped.
This is an example C# code:
public int DisableSource(ManagementScope scope, int ErrorSourceId)
{
try
{
ManagementObject obj = new ManagementObject();
ManagementPath path = new ManagementPath(scope.Path + ":WHEAErrorSourceMethods.InstanceName='WHEA_WMI_PROVIDER0'");
obj.Path = path;
obj.Get();
ManagementBaseObject inParams =
obj.GetMethodParameters("DisableErrorSourceRtn");
inParams["ErrorSourceId"] = Int32.Parse(ErrorSourceId.ToString());
ManagementBaseObject outParams =
obj.InvokeMethod("DisableErrorSourceRtn",
inParams, null);
WHEAservice.WHEAService.EventMsg("Status=" + outParams["Status"].ToString());
obj.Dispose();
return int.Parse(outParams["Status"].ToString());
}
catch (ManagementException e)
{
#if DEBUG
WHEAservice.WHEAService.EventErr("Failed DisableSource for " + ErrorSourceId + ", WMI exception thrown: " + e.ToString());
#endif
return 5;
}
catch (Exception e)
{
WHEAservice.WHEAService.EventErr("Failed DisableSource (this can be normal) for " + ErrorSourceId + ", exception thrown: " + e.ToString());
return 5;
}
}
No RepliesBe the first to reply