none
WMI Get logged in user (non-admin)

    Question

  • 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 If 
    

    If 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.

     
    Friday, November 23, 2012 3:49 AM

Answers

  • 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.


    ¯\_(ツ)_/¯

    Friday, November 23, 2012 5:39 AM

All replies

  • 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.


    ¯\_(ツ)_/¯

    Friday, November 23, 2012 5:39 AM
  • There is a nice program to compile your vbs into exe and give other credentials inside the exe

    h t t p :/ / w w w .v b s e d i t. c o m
    (remove the spaces, my account is not verified yet to post links) you have the option to use other credentials e.q. a serviceaccount or other account what doesn't expire, this other credentials are compile in the exe, so when running the exe-file what happens is the vbs uses it like you would use a run as command, so every "normal" user can use the exe like he/she is an admin.

    Hope it helps, the tools if free to use, but it's not expensive, updates the program from time to time and most important, the license is a lifetime license, pay once and it works for ever!

    Friday, April 11, 2014 11:02 AM
  • (remove the spaces, my account is not verified yet to post links)

    Click the link below, you'll find a sticky thread to post in to have your account verified:

    http://social.technet.microsoft.com/Forums/en-US/home?forum=reportabug

    Side note - this method doesn't really protect the password. I highly recommend against this, unless you have no other option and don't mind curious people having the password.


    Don't retire TechNet! - (Don't give up yet - 12,830+ strong and growing)

    Friday, April 11, 2014 12:51 PM