欢迎光临
我们一直在努力

Win32_LogicalMemoryConfiguration在win7下无法使用

strComputer = "."

Set objSWbemServices = GetObject("winmgmts:\" & strComputer)
Set colSWbemObjectSet = _
objSWbemServices.InstancesOf("Win32_LogicalMemoryConfiguration")

For Each objSWbemObject In colSWbemObjectSet
Wscript.Echo "Total Physical Memory (kb): " & _
objSWbemObject.TotalPhysicalMemory
Next
这段代码在win7下无法运行报错(null): 0x80041010 在win2003下可以运行,win7下已经取消Win32LogicalMemoryConfiguration类
以下是替代方法
strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery(

"SELECT * FROM Win32_PhysicalMemory",,48)
For Each objItem in colItems
Wscript.Echo "———————————–"
Wscript.Echo "Win32_PhysicalMemory instance"
Wscript.Echo "———————————–"
Wscript.Echo "Capacity: " & objItem.Capacity
Next
用Win32_PhysicalMemory instance代替之

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。