在查询中挂起 VBScript
我从一位最近退休的同事那里继承了一段代码,该代码获取机器上的总物理内存,当我在 Windows XP 和 Server 2003 上执行以下操作时,它工作正常:
memSize = 0
set colItems = wmi.execQuery("select * from Win32_LogicalMemoryConfiguration")
for objItem in colItems
memSize = memSize + objItem.TotalPhysicalMemory
next
但是,在 Windows Server 2008 上,它似乎挂起for 语句(基于每行后面的大量调试语句,示例中未显示)。
有什么想法吗?
I inherited a piece of code from a recently-retired colleague that gets the total physical memory on a box and, when I perform the following on Windows XP and Server 2003, it works fine:
memSize = 0
set colItems = wmi.execQuery("select * from Win32_LogicalMemoryConfiguration")
for objItem in colItems
memSize = memSize + objItem.TotalPhysicalMemory
next
On Windows Server 2008 however, it appears to hang in the for
statement (based on copious debugging statements after every line which are not shown in the example).
Any ideas why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Win32_LogicalMemoryConfiguration
类已被弃用。 请尝试使用 Win32_OperatingSystem 类。 它应该在 Server 2008 上给出正确的结果。我相信您感兴趣的属性是
TotalVisibleMemorySize
。The
Win32_LogicalMemoryConfiguration
class has been deprecated. Try the Win32_OperatingSystem class instead. It should give the proper results on Server 2008.I believe the property you're interested in is
TotalVisibleMemorySize
.