I'm trying to create an installer using Inno Setup when I encounter this problem, everything else is being installed, but the registry keys are not being installed in the current user. I found this helpful topic (many thanks!):
Inno Setup Creating registry key for logged in user (not admin user)
This solved the part for adding registry keys, like this:
[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):
It added: HKCU\Software\myprinter OutputFile REG_SZ c:\users\admin\appdata\local\temp\
Is required: 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 admin temp (of course)
Although according to the online help it should work for the user that started the setup, it seems it does not, in my case. (with or without the postinstall
flag)
runasoriginaluser
Valid only in a [Run] section. If this flag is specified and the system is running Windows Vista or later, the spawned process will execute with the (normally non-elevated) credentials of the user that started Setup initially (i.e., the "pre-UAC dialog" credentials).
This is the default behavior when the postinstall flag is used.
If a user launches Setup by right-clicking its EXE file and selecting "Run as administrator", then this flag, unfortunately, will have no effect, because Setup has no opportunity to run any code with the original user credentials. The same is true if Setup is launched from an already-elevated process. Note, however, that this is not an Inno Setup-specific limitation; Windows Installer-based installers cannot return to the original user credentials either in such cases.
This flag cannot be combined with the runascurrentuser flag.
Note: running Inno Setup: 5.5.9 (a) and Windows 10