Markus Heckmann
Markus Heckmann

Reputation: 325

Write custom string value into SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall with Inno Setup

During installation, I'd like to write a custom string value into the automatically created registry key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MyApp.2020_is1

I tried to do this in the [Registry] section of my iss script but it seems to be ignored.

Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#MyAppName}.{#MyAppVersion}_is1"; ValueData: "some tag"; Flags: uninsdeletekey; ValueType: string; ValueName: "CustomTag"

Is this generally discouraged or am I missing something particular? I do have PrivilegesRequired=admin in the [Setup] section.

With the possibility to install multiple builds of my app side-by-side, I want to give the user the possibility to add a descriptive tag so that they can identify the build not only via build number but also the tag.

As I'm searching the registry for previous builds anyways, I was trying to add a custom value into the uninstall key instead of having to reference another key to find the custom tag.

Upvotes: 1

Views: 335

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202118

The Uninstall entry is created as one of the last steps of the installation. So also after the [Registry] section is processed. Check the Installation order. And when the entry is created, its previous contents is completely removed, including your some tag value.

As @Bill_Stewart already commented, the correct way is to use SetPreviousData/GetPreviousData.

If you really wanted to use your own custom code to write the entry, you will have to do it from Pascal Script in CurStepChanged(ssPostInstall) event (triggered after the Uninstall entry is created).


If you want to allow users to distinguish the installation, the tag must go to AppName or AppVerName or UninstallDisplayName.

If you need to allow parallel installations, the installations must have different AppId – which is a part of the uninstaller key name, so no additional tag should be needed.

Upvotes: 1

Related Questions