WMI Win32_OperatingSystem OSArchitecture field causes exception

Posted by Andrew J. Brehm on Stack Overflow See other posts from Stack Overflow or by Andrew J. Brehm
Published on 2010-03-22T11:48:51Z Indexed on 2010/03/22 11:51 UTC
Read the original article Hit count: 969

Filed under:
|

I am trying to get information on the version of Windows installed from WMI. Most fields work. I can get the operating system "Name" as well as the "Version", both are fields of the Win32_OperatingSystem object I have.

But another field "OSArchitecture" generates an exception ("Not found").

    strScope = "\\" + strServer + "\root\CIMV2"
    searcher = New ManagementObjectSearcher(strScope, "SELECT * FROM Win32_OperatingSystem")

    For Each mo In searcher.Get

        strOSName = mo("Name")
        strOSVersion = mo("Version")
        strOSArchitecture = mo("Architecture")
        strStatus = mo("Status")
        strLastBoot = mo("LastBootUpTime")

    Next

The documentation says that the field ought to exist and is a String:

http://msdn.microsoft.com/en-us/library/aa394239(VS.85).aspx

Any ideas?

© Stack Overflow or respective owner

WMI Win32_OperatingSystem OSArchitecture field causes exception

Posted by Andrew J. Brehm on Stack Overflow See other posts from Stack Overflow or by Andrew J. Brehm
Published on 2010-03-22T11:39:28Z Indexed on 2010/03/22 11:41 UTC
Read the original article Hit count: 969

Filed under:
|

I am trying to get information on the version of Windows installed from WMI. Most fields work. I can get the operating system "Name" as well as the "Version", both are fields of the Win32_OperatingSystem object I have.

But another field "OSArchitecture" generates an exception ("Not found").

   strScope = "\\" + strServer + "\root\CIMV2"
        searcher = New ManagementObjectSearcher(strScope, "SELECT * FROM Win32_OperatingSystem")

        For Each mo In searcher.Get

            strOSName = mo("Name")
            strOSVersion = mo("Version")
            strOSArchitecture = mo("Architecture")
            strStatus = mo("Status")
            strLastBoot = mo("LastBootUpTime")

        Next

Ignore the for each loop, I don't think it has anything to do with the field missing. The documentation says that the field ought to exist and is a String:

http://msdn.microsoft.com/en-us/library/aa394239(VS.85).aspx

Any ideas?

© Stack Overflow or respective owner

Related posts about wmi

Related posts about .NET