views:

806

answers:

2

Hi below is the code, at this point i get error message:

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


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

Complete rewrite.

Here is the code generated by WMI Code Creator, with very minor editing.

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
Remou
Hi, thanks for the reply, but can you please point out where have i forgot to put back slash as i just compared the code with your's and they are exactly same
The post was edited and the original problem no longer visible. I have quoted the original post in my reply. You can view the original post by clicking "edited n minutes go".
Remou
Hi Remou thanks for the update, but am pasting my whole code, can you please make the changes as i am struglling, i have done as what you said but it still gives me error:**********************************
Remou, the original post did have impersonate}!\\, but I think the SO formatter uses \ as an escape char outside of code, so \\ becomes \ (see how it did this in your edit as well).
Patrick Cuff
I will note that in future :)
Remou
A: 

Do you know this tool WMI Code Creator, good for learn WMI, has many examples.

lsalamon