WMI Get logged in user (non-admin)
-
Friday, November 23, 2012 3:49 AM
I've got a vbs script that uses WMI to get a list of logged in users on a computer. It looks at the "GetOwner" property of all explorer.exe processes on the machine to get the logged in users. Here is the script:
strComputer = "ComputerName" dim objWMIService, objEnum, obj, outParams Set objWMIService = GetObject("winmgmts:{impersonationLevel=Impersonate, authenticationLevel=PktPrivacy}!\\" & strComputer & "\root\cimv2") set objEnum = objWMIService.execQuery("select __relpath from win32_process where caption = 'explorer.exe'") If objEnum.Count then for each obj in objEnum set outParams = obj.ExecMethod_("GetOwner") currentUser = Trim(outParams.User) next End IfIf a user isn't an admin user they can't access the "GetOwner" property of the process (error gets thrown on the line: set outParams = obj.ExecMethod_("GetOwner")).
Is there a way I can grant a non-admin user to this property without making them an admin user?
Is there another way to get logged in users on a machine without being an admin user?
Note, the solution has to work on Win 7 OS.
All Replies
-
Friday, November 23, 2012 5:39 AM
No - only an admin can run this code.
The terminal server snapin can allow a standard user to see and communicate with other users on a terminal server.
¯\_(ツ)_/¯
- Marked As Answer by IamMredMicrosoft Employee, Owner Thursday, December 06, 2012 5:45 AM

