Inno Setup Create a registry key for logging in (not an administrator)

I am trying to create an installer using the Inno installation, when I encounter this problem, everything else is installed, but the registry keys are not installed in the current user, I can not find it in HKEY_CURRENT_USER , But when I try to run Regedit as an administrator, the registry is installed there. I have UAC enabled and check with an administrator account to start the installation, why is this happening?

Here is the Registry section

 [Registry] Root: HKCU; Subkey:Software; Flags: uninsdeletekey; ValueName:ABS; ValueType:string; ValueData:ABS; Root: HKCU; Subkey:Software\Microsoft\Office\Word\Addins\ABS.ScriptManager; Flags: uninsdeletekey; Root: HKCU; Subkey:Software\Microsoft\Office\Word\Addins\ABS.ScriptManager; ValueName:Description; ValueType:string; ValueData:Script Manager; Flags: uninsdeletekey; 

Note. I am running a 32-bit version of Windows 7

+1
source share
3 answers

I do not think that you can explicitly write down the registry keys of the logged-in user from Inno Setup. You can write to the registry key a user that only the installer launches.

You can write to any (or all) user registry keys through HKEY_USERS , but I don’t know if you can tell which user is logged in.


But you can run an external application that writes the registry key as part of the installation using the runasoriginaluser flag or the ExecAsOriginalUser function.

You can use reg.exe :

 [Run] Filename: reg.exe; Parameters: "ADD HKCU\Software\MyProgram /v Foo /t REG_SZ /d Bar"; \ Flags: runasoriginaluser runhidden 

or

 procedure CurStepChanged(CurStep: TSetupStep); var Params: string; ResultCode: Integer; begin if CurStep = ssPostInstall then begin Log('Adding registry key for original user'); Params := 'ADD HKCU\Software\xxxx /v Foo /t REG_SZ /d Bar'; if ExecAsOriginalUser( 'reg.exe', Params, '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 0) then begin Log('Added registry key for original user'); end else begin Log('Error adding registry key for original user'); end; end; end; 

Credits for the idea: @Markus

+1
source

From the wording of your question, it sounds like this because you are "checking the administrator account to start the installation." If this is the case, and you enter another account (from the one with which you are logged in) at the UAC prompt, the current user actually becomes the administrator account that you just entered at the UAC prompt, and not the account that you registered in s. You may need to use the runasoriginaluser function, which will use the registered user credentials, rather than the account entered at the UAC prompt.

0
source

in the [Run] section with: File name: reg.exe; Parameters: "IMPORT ..." and flag: runascurrentuser!

0
source

Source: https://habr.com/ru/post/915360/


All Articles