Creating Registry Key under HKCU with Elevated Instataller - Advanced Installer Community
nickrsan
Posts: 3
Joined: Mon Nov 10, 2014 9:12 pm

Creating Registry Key under HKCU with Elevated Instataller

Hi all,

I've been working on an installer in tandem with the product's development for about 4 months. I'm having an issue that worked in an older version of the installer I created, but which fails to work now. I have an installer that needs to be elevated via UAC for part of its installation, and that works successfully, but it needs to insert registry entries under HKCU in the context of the user who ran the installer, not the administrator account. This worked for me in older versions of an installation file I created, but does not work now. I can't seem to figure out what changed. Here is how I have my file set up:

Build Config: Single EXE with resources inside
Package Type: 32-bit package
Installation Type: Per-user only
Run as administrator: Unchecked - Execution Level: As Invoker

I'm loading the registry entries with Advanced Installer's configuration panel for them. I've tried just putting the entries directly under HKEY_CURRENT_USER, and under the "Current user/Local machine" section with the same results. In each case, registry entries are placed for the administrator rather than the Invoker

I get the following log messages for the registry entries when it is run (replacing actual names with MyCompany and MySoftware):
Action 11:49:06: WriteRegistryValues. Writing system registry values
MSI (s) (10:64) [11:49:06:549]: Executing op: ProgressTotal(Total=6,Type=1,ByteEquivalent=13200)
MSI (s) (10:64) [11:49:06:549]: Executing op: RegOpenKey(Root=-1,Key=Software\Caphyon\Advanced Installer\LZMA\{7745E751-5C11-4430-AD1A-F913E04B6DBB}\2.0.1,,BinaryType=0,,)
MSI (s) (10:64) [11:49:06:549]: Executing op: RegAddValue(Name=AI_ExePath,Value=C:\Users\mysoftwaretest\Desktop\setup_2.0.1_Update.exe,)
WriteRegistryValues: Key: \Software\Caphyon\Advanced Installer\LZMA\{7745E751-5C11-4430-AD1A-F913E04B6DBB}\2.0.1, Name: AI_ExePath, Value: C:\Users\mysoftwaretest\Desktop\setup_2.0.1_Update.exe
MSI (s) (10:64) [11:49:06:549]: Executing op: RegOpenKey(Root=-1,Key=Software\MyCompany\MySoftware,,BinaryType=0,,)
MSI (s) (10:64) [11:49:06:549]: Executing op: RegCreateKey()
WriteRegistryValues: Key: \Software\MyCompany\MySoftware, Name: , Value:
MSI (s) (10:64) [11:49:06:549]: Executing op: RegOpenKey(Root=-1,Key=Software\MyCompany\MySoftware\location,,BinaryType=0,,)
MSI (s) (10:64) [11:49:06:549]: Executing op: RegAddValue(,Value=C:\ProgramData\MyCompany\MySoftware\,)
WriteRegistryValues: Key: \Software\MyCompany\MySoftware\location, Name: , Value: C:\ProgramData\MyCompany\MySoftware\
MSI (s) (10:64) [11:49:06:565]: Executing op: RegCreateKey()
WriteRegistryValues: Key: \Software\MyCompany\MySoftware\location, Name: , Value:
MSI (s) (10:64) [11:49:06:565]: Executing op: RegOpenKey(Root=-2147483647,Key=Software\MyCompany\MySoftware\location,,BinaryType=0,,)
MSI (s) (10:64) [11:49:06:565]: Executing op: RegAddValue(,Value=C:\ProgramData\MyCompany\MySoftware\,)
WriteRegistryValues: Key: \Software\MyCompany\MySoftware\location, Name: , Value: C:\ProgramData\MyCompany\MySoftware\
MSI (s) (10:64) [11:49:06:565]: Executing op: RegAddValue(,Value=C:\ProgramData\MyCompany\MySoftware\,)
WriteRegistryValues: Key: \Software\MyCompany\MySoftware\location, Name: , Value: C:\ProgramData\MyCompany\MySoftware\
Any thoughts on where I might be configuring this incorrectly? Thank you in advance for your help!

Edit: I've attached a compressed file with the logs and project, just in case that is needed. Thanks!
logs_and_project.7z
Project file and sample install log
(910.25 KiB) Downloaded 338 times
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Creating Registry Key under HKCU with Elevated Instatall

Hi,

According to your log you are running the build "DFW_Main_Updates_Build". This build is configured to install per-machine and request the highest privileges available. (when you check these options in Install Parameters page make sure you select the build from the toolbar) Thus your installation will run under full admin account. (The option per-machine if admin, per-user otherwise automatically defaults to per-machine on Win 7, due to UAC behavior)

When you run the installer under an admin account, all per-user resources get written under the admin user, not under the user from where the installation got launched. You cannot change this.

From what I see your project contains a service, which gets installed by all builds, so you need a per-machine installation as services cannot be installed per-user.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”