WMI Win32_OperatingSystem OSArchitecture 字段导致异常
我正在尝试从 WMI 获取有关安装的 Windows 版本的信息。大多数领域都有效。我可以获得操作系统“名称”和“版本”,两者都是我拥有的 Win32_OperatingSystem 对象的字段。
但另一个字段“OSArchitecture”生成异常(“未找到”)。
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("OSArchitecture")
strStatus = mo("Status")
strLastBoot = mo("LastBootUpTime")
Next
该文档说该字段应该存在并且是一个字符串:
http://msdn.microsoft.com/en-us/library/aa394239(VS.85).aspx
有什么想法吗?
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("OSArchitecture")
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您最初的问题有这样一行:
应该是:
现在您已经确认这是问题中的一个简单拼写错误(不是您的实际代码),另一种可能性是您正在服务器 2003、2000、NT4、 XP 或 Me/98/95,其中文档将
OSArchitecture
键列为不可用?Your original question had the line:
which should have been:
Now that you've confirmed that was a simple typo in the question (not your actual code), the other likelihood is that you are running on either Server 2003, 2000, NT4, XP or Me/98/95, where the documentation lists the
OSArchitecture
key as unavailable?要查看可用属性的当前(运行时)列表,请查看
Properties
属性。在控制台应用程序中,它看起来像:
在我的 XP 安装中,列出的 61 个属性名称中没有出现
OSArchitecture
。To view a current (runtime) list of available properties, walk the
Properties
attribute.In a console application, it looks like:
On my XP installation, no
OSArchitecture
appears in the 61 property names listed.