How to get current username (non-admin) when running script as Admin?
Posted: 11 Aug 2016, 19:40
I've created an installer that needs to run as Administrator to install certain registry keys and files. I need to get the name of the current logged in user to find the proper current user registry SID, but obviously running as admin will show the current user (A_Username) as the administrator credentials, not the actual user.
What I do to work around the problem, is run the program unelevated, request elevation through RunAs and pass the %A_Username% to the command line, so running elevated will have the proper name in %1%.
Is there an easy way to get the actual logged in username when elevated, rather than this workaround?
What I do to work around the problem, is run the program unelevated, request elevation through RunAs and pass the %A_Username% to the command line, so running elevated will have the proper name in %1%.
Is there an easy way to get the actual logged in username when elevated, rather than this workaround?