dybalabj
Posts: 58
Joined: Thu Jan 09, 2014 2:00 am

Append REG_EXPAND_SZ registry value?

Thu Aug 09, 2018 7:48 pm

Hello,

I have an existing REG_EXPAND_SZ registry key that I want to add a new path to. However, the Edit Registry Entry dialog only lets me select "Append to existing value" for REG_SZ and REG_MULTI_SZ. How can I append to a REG_EXPAND_SZ, or is there a reason I should not be allowed to do this?

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: Append REG_EXPAND_SZ registry value?

Tue Aug 14, 2018 1:24 pm

Hello,

We apologize for our delayed reply.

Unfortunately this is due to a Windows Installer limitation. We use the built-in Windows Installer registry support and this do not have the option to prepend or append the setup reg value to the reg value on disk.

However, as a workaround solution you can simply create a registry search (REG_SEARCH) which will get the current reg value on disk. Then use a formatted property reference in the "Data" field of you registry from the setup project. Thus at install time, if the registry is found on disk its value will be saved into the property name (REG_SEARCH) which actually is an installer property. Then the installer property value will be expanded when installing the reg value.

Here are the steps you could follow:

1. go to "Search" page and add a registry value search (REG_SEARCH) which will search for your reg value on disk
2. go to "Registry" page and double click on your registry value
3. edit its "Data" field like so:

Code: Select all

[REG_SEARCH]
current installer value
4. save and rebuild the setup project

Hope this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

dybalabj
Posts: 58
Joined: Thu Jan 09, 2014 2:00 am

Re: Append REG_EXPAND_SZ registry value?

Sat Aug 18, 2018 11:25 pm

Daniel,

Thanks for the tips, that got me most of the way there.

However, I want to make sure the I don't append the same value to the registry entry multiple times if the user uninstalls and reinstalls the application.

I wanted to set a condition of the Registry entry component of NOT ( REG_SEARCH ~>< MyDir ), but the Folder button in the Edit Condition dialog is disabled. Since I'm appending a directory to this registry entry, I need to wait until the user selects the install directory so that my path is resolved before I can edit the registry.

I also tried modifying the desired registry path with an inline PowerShell script, but it only appended my path up to the first space (C:\Program).

Any suggestions on how to make sure I don't append the same folder path to a registry value on a reinstall?

dybalabj
Posts: 58
Joined: Thu Jan 09, 2014 2:00 am

Re: Append REG_EXPAND_SZ registry value?

Thu Aug 23, 2018 3:00 pm

Do you have any other suggestions regarding my last update? My deadline for delivering this application is approaching.

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: Append REG_EXPAND_SZ registry value?

Mon Aug 27, 2018 3:05 pm

Hello,

I apologize for my delayed reply.

To achieve what you want you could use another property (e.g. PROP_DIR) to be set to the install directory path you want to be appended to your registry value. For instance, your registry value data could be set like this into your "Registry" page:

Code: Select all

[REG_SEARCH]
[PROP_DIR]
Then, you can add a "Set installer property" custom action, in "Custom Actions" page and scheduled after "Install Execution Stage -> Searches" action group, which will set to empty string the "PROP_DIR" property when the install condition is false (i.e. REG_SEARCH ~>< MyDir).
  • Property: PROP_DIR
    Value: {}
    Condition: REG_SEARCH ~>< MyDir
Thus, every time the setup package is reinstalled and the install directory path already exists in the current registry value on disk the "PROP_DIR" property value will be set to empty string, thus nothing will be appended to your reg value.

Hope this helps.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”