WMI Win32_OperatingSystem OSArchitecture field causes exception
- by Andrew J. Brehm
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?