1
votes

From the Inno Setup Help:

dontcreatekey

When this flag is specified, Setup will not attempt to create the key or any value if the key did not already exist on the user's system. No error message is displayed if the key does not exist.

Typically this flag is used in combination with the uninsdeletekey flag, for deleting keys during uninstallation but not creating them during installation.

My program creates a registry value (of type string) under the Current User autostart section, but only if the user explicitly does so from the settings screen.

I want that entry to be cleaned up by the uninstaller, so I added the following to my Inno Setup project:

[Registry]
Root: HKCU; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "this_is_a_test"; Flags: dontcreatekey uninsdeletevalue

However that doesn't seem to work. I feel that the dontcreatekey flag only applies to "keys"ยน and not to "values". If so, how can I accomplish this?

(1) Assuming the "key" would be "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" (which will always exists prior to installation), and the "value" would be the entry of type string residing inside that key.

1

1 Answers

3
votes

Use ValueType: none or omit the ValueType parameter altogether:

If none (the default setting) is specified, Setup will create the key but not a value. In this case the ValueName and ValueData parameters are ignored.

Though note that the documentation is not completely correct. When combined with uninsdeletevalue flag, the ValueName is not ignored.

[Registry]
Root: HKCU; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; \
    ValueType: none; ValueName: "this_is_a_test"; Flags: dontcreatekey uninsdeletevalue