I am trying to create an installer using Inno Setup, when I encounter this problem, everything else is installed, but the registry keys are not installed by the current user. I found this useful topic (thank you very much!):
Inno Setup Create a registry key for logging in (not for the administrator user)
This solved the part for adding registry keys, for example:
[Run] Filename: reg.exe; \ Parameters: "ADD ""HKCU\Software\myprinter"" /v OutputFile /t REG_SZ /d ""{localappdata}\temp\\"""; \ Flags: runasoriginaluser runhidden
My problem:
{localappdata} refers to the admin user (admin), not the local user (test):
He added: HKCU \ Software \ myprinter OutputFile REG_SZ c: \ users \ admin \ appdata \ local \ temp \
Requires: HKCU \ Software \ myprinter OutputFile REG_SZ c: \ users \ test \ appdata \ local \ temp \
The software does not work because it is not allowed to use the administrative temperature (of course)
Although according to the online help it should work for the user who started the setup, it seems that in my case this is not so. (with or without postinstall flag)
runasoriginaluser
Valid only in the [Run] section. If this flag is specified and the system is running Windows Vista or later, the spawned process will execute with (usually not elevated) user credentials that the installation originally started (that is, the "pre-UAC dialog" credentials).
This is the default behavior when using the postinstall flag.
If the user starts the installation program by right-clicking its EXE file and selecting "Run as administrator", this flag, unfortunately, will not be because the installation program does not have the ability to run any code using the user's original credentials. The same is true if the installer is running with an already elevated process. Please note, however, that this is not an Inno Installation Restriction; Installers on the Windows installer cannot return the original user credentials either in such cases.
This flag cannot be combined with the runascurrentuser flag.
Note: starting Inno Setup: 5.5.9 (a) and Windows 10