I'm sharing a solution to a common UAC elevation issue.
The Issue: When you use RequestExecutionLevel admin, variables like $PROFILE and $APPDATA point to the Admin account. If you want to install a config file for the original user, you usually have to resort to plugins that hunt for explorer.exe.
The Fix: I found that the old "Explorer Process" method is getting flagged by modern AV heuristics as malicious (Token Stealing). I wrote a small open-source plugin, GetOriginalUser, that uses the WTS (Windows Terminal Services) API instead.
- Zero AV Detections: It uses standard OS APIs to query the Session Manager.
- No Process Handles: It doesn't touch other processes, so it's safer and more stable.
- Correct Paths: Resolves User Shell Folders from the Registry to handle redirected folders.
Link: https://github.com/rizonesoft/GetOriginalUser
Usage: You can use the CLI tool with nsExec (simplest) or call the DLL directly with the System plugin.
CLI Example:
Section "Main"
File "GetOriginalUser.exe"
# Get the original user's Documents folder
# Value names map to Registry 'User Shell Folders' (Personal, AppData, Desktop, etc.)
nsExec::ExecToStack '"$PLUGINSDIR\GetOriginalUser.exe" --env Personal'
Pop $0 ; Return Code
Pop $1 ; The Path (e.g., C:\Users\Bob\Documents)
DetailPrint "Real User Docs: $1"
SectionEnd