1

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
4
  • The recent edit removed an important problem, which makes it difficult to offer sensible corrections. :(
    – Fionnuala
    Mar 20, 2009 at 10:26
  • @Spida; can you post all the code; this snippet works for me. Also, what OS are you running this on? Mar 20, 2009 at 10:41
  • What Spida posted is missing a \ he needs to confirm if that is in the code or was just a typo here.
    – EBGreen
    Mar 20, 2009 at 10:42
  • Ok, so based on the comment below I put the \ back in but left the formatting.
    – EBGreen
    Mar 20, 2009 at 10:44

1 Answer 1

2

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
6
  • 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
    – Spida
    Mar 20, 2009 at 9:57
  • 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".
    – Fionnuala
    Mar 20, 2009 at 10:24
  • 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: **********************************
    – Spida
    Mar 20, 2009 at 10:34
  • sComputer="." Set oWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2") Set colComputer=oWMIService.ExecQuery("Select * from Win32_ComputerSystem")
    – Spida
    Mar 20, 2009 at 10:36
  • 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). Mar 20, 2009 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.