I'm trying to write a vbscript that takes the currently logged in users on a terminal server and does something else with that information. I whittled it down to the most basic script based on the line on which I was getting the error.
'On Error Resume Next
dim colSessions, objWMI, objitem
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colSessions = objWMI.ExecQuery("Select * from Win32_LogonSession")
For Each objitem I开发者_开发技巧n colSessions
WScript.Echo objitem.LogonId
Next
I am getting the following error on line 6 (where the query is for Win32_LogonSession):
VBScript runtime error: Object required: ' '
Why am I getting this error? What am I doing wrong? I can't find anyone else reporting this problem (why am I always the first to find and report them?).
Check the variable names. oWMI (on the GetObject line) should be objWMI.
精彩评论