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
From stackoverflow
-
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 : 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".Patrick Cuff : 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).Remou : I will note that in future :) -
Do you know this tool WMI Code Creator, good for learn WMI, has many examples.
0 comments:
Post a Comment