Trying to get Win32_BIOS version using path string

I puzzle over how to do this. I found a link about 2 months ago that showed how to get one item from a wmi call.

class Sample
{
    public static int Main(string[] args)
    {
        ManagementObject o =
            new ManagementObject("Win32_Service.Name='Alerter'");

        //or with a full path :

        ManagementObject mObj =
            new ManagementObject(
            "\\\\MyServer\\root\\MyApp:MyClass.Key='abc'");

        return 0;
    }
}

which I thought was awesome because it returns results much faster than by doing a full search through WMI to get 1 property. I played with it and got this code to work with Win32_ComputerSystem, and I think I even got it to work with Win32_DiskDrive and, possibly, BaseBoard, but I can’t remember my head since I can’t find this particular code bit So, now I'm trying to get it to work with Win32_BIOS and continue to work out. I can't seem to find the key property so that it returns a valid result.

I tried the following paths to no avail.

\\.\root\cimv2:Win32_BIOS.SoftwareElementState=3
\\.\root\cimv2:Win32_BIOS.TargetOperatingSystem=0
\\.\root\cimv2:Win32_BIOS.SoftwareElementState=3,TargetOperatingSystem=0

2 , Win32_BIOS, - .. - , . , BIOS. , , . ?

+3
2

WMI, , Name, SoftwareElementID, SoftwareElementState, TargetOperatingSystem Version.

:

Win32_BIOS.Name="Ver 1.00 BIOS A05 PARTTBL",SoftwareElementID="Ver 1.00 BIOS A05 PARTTBL",SoftwareElementState=3,TargetOperatingSystem=0,Version="DELL   - 6040000"

, , , Wmi delphi.

enter image description here

+3

WMI . , , . , . , , ConnectionOptions.

String path = @"\\{0}\ROOT\CIMV2";
String BiosVersion = String.Empty;

ConnectionOptions co = new ConnectionOptions();
ManagementScope scope = 
    new ManagementScope(String.Format(path, "."), co);

scope.Connect();

ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_BIOS");
ManagementObjectSearcher search = new ManagementObjectSearcher(scope, query);

ManagementObjectCollection moc = search.Get();

foreach (ManagementObject mo in moc)
{
    BiosVersion = (String)mo["SMBIOSBIOSVersion"];
}
0

All Articles