Hi everyone,
I wanted to share a small open-source utility I built to solve a recurring headache I’ve had with elevated installers (PrivilegesRequired=admin).
The Problem: As many of you know, once an installer elevates to Admin, constants such as {userdocs} or {userappdata} point to the Administrator’s profile. If you need to write to the actual user's config folder (the person running the desktop), you generally have to use workarounds or registry hacks.
I previously used the GetShellWindow method (finding the Explorer process) to identify the desktop owner. While this worked, recently it started triggering "Heuristic" false positives in several Antivirus engines (like Cynet and Acronis) because it mimics "Token Stealing" malware techniques.
The Solution: I wrote a new DLL that uses the Windows Terminal Services (WTS) API instead of process hunting.
AV Safe: It uses legitimate Admin APIs (WTS) instead of process injection/handles, so it currently sits at 0 detections.
Robust: It works correctly with Fast User Switching and RDP (checking for WTSActive).
Registry-based: It resolves paths via HKU\<SID>\... so it respects folder redirection (e.g., if the user moved Documents to a network drive).
GitHub: https://github.com/rizonesoft/GetOriginalUser
Usage: It exports standard C-style functions, so it’s easy to call from [Code].
It’s MIT licensed. I hope this saves someone else the time I spent debugging session IDs!
On Saturday, January 24, 2026, 06:48:30, Derick Payne (Derick) wrote:
The Problem: As many of you know, once an installer elevates to Admin, constants such as {userdocs} or {userappdata} point to the Administrator’s profile. If you need to write to the actual user's config folder (the person running the desktop), you generally have to use workarounds or registry hacks.
Never use any user-specific folder from an installer that isn't running with PrivilegesRequired=lowest, because it will not work when your installer is run by an actual administrator (eg. as part of deployment scripts), as the user that will actually be running your program hadn't even logged in on the computer yet, so there's no way to get those files to them at install time.
--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/innosetup/48b445e2-93c7-402a-bf15-9923e76f1c18n%40googlegroups.com.
For that migration to work correctly, the installer must launch the application as the Standard User immediately post-install. If we use the standard Inno [Run] section, the app inherits Admin rights, performs the migration as Admin
Touché, Martijn! You are absolutely right—I overlooked that modern Inno handles the privilege drop in the [Run] section automatically. Thanks for the correction.
However, the 'Seed & Migrate' pattern exposed a different gap that [Run] doesn't solve: Path Resolution in Pascal Script.
Even if Inno launches the app as the user, the installer script itself (running as Admin) still resolves constants like {userappdata} to the Administrator's profile.
I need the installer to know the Standard User's actual AppData path during the installation so I can write a 'Receipt' (e.g., to uninstall.ini). This allows the Uninstaller to clean up the user's config files later, even if the Uninstaller is run by a different Admin.
So, while Inno handles the Execution ([Run]), my tool handles the Detection (GetOriginalUserAppData) in the [Code] section, allowing the script to log exactly where the data is going to end up.
I'll update the README to reflect that distinction. Thanks again!
I overlooked that modern Inno handles the privilege drop in the [Run] section automatically.
This allows the Uninstaller to clean up the user's config files later, even if the Uninstaller is run by a different Admin.
--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/innosetup/a80755c7-fdbe-47e1-9730-ac53b2ca0d52n%40googlegroups.com.