title: Check if a WMI Management Class exists
body: <p>I'm in .Net 5 and accessing WMI in essential like so:</p>
  <pre><code>ManagementScope managementScope = new(&quot;\\\\.\\ROOT\\WMI&quot;);
  ManagementPath managementPath = new(&quot;BatteryFullChargedCapacity&quot;);
  ManagementClass managementClass = new(managementScope, managementPath, null);
  ManagementObjectCollection managementObjectCollection = managementClass.GetInstances();
  </code></pre>
  <p>The problem I'm having is that not every WMI Path is always present. Like in this example the BatteryFullChargedCapacity exist only on battery powered devices like laptops. The management class is still created but calling <code>GetInstances()</code> leads to an exception.</p>
  <p>Currently I'm catching the exception but I would much rather check if the class exist / has Instances and react on the result. Does anyone now how to do this?</p>
  <p>Any help is much appreciated!</p>