VB脚本GetObject方法错误...请帮助WMI

时间:2009-03-20 09:28:15

标签: vbscript wmi

此时我收到错误消息:

Set objWMI = GetObject("winmgmts:" _
          & "{impersonationLevel=impersonate}!\\" _
          & strComputer & "\root\cimv2")

Error: Invalid procedure call or Argument: "GetObject"
Code: 800A005
Source: Microsoft VBScript Runtime error

1 个答案:

答案 0 :(得分:2)

完全重写。

以下是WMI Code Creator生成的代码,编辑很少。

strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_ComputerSystem",,48) 
For Each objItem in colItems 
    MsgBox "CurrentTimeZone: " & objItem.CurrentTimeZone
Next