How to programmatically check which version of WMI is installed

How to programmatically check which version of WMI (Windows Management Instrumentation) is installed using delphi or C #?

early.

+3
source share
1 answer

Try:

        using System.Management;

        ManagementObjectSearcher query = new
            ManagementObjectSearcher("SELECT * FROM Win32_WMISetting") ;
        ManagementObjectCollection items = query.Get();
        foreach (ManagementObject mo in items)
        {
            System.Console.WriteLine(mo["BuildVersion"]);
        }

There itemsshould be only one in the collection , since this parameter is singleton. "BuildVersion" is the version of WMI that is installed.

EDIT:

The following Helen remark provides an even more concise solution:

System.Console.WriteLine(
       (new ManagementObject("Win32_WMISetting=@"))["BuildVersion"]);
+5
source

Source: https://habr.com/ru/post/1740254/


All Articles