Registry Key

A Registry Key object represents a registry key for installation or removal. You can add or remove keys, and you can optionally remove all their subkeys and values as well.

Installation or removal of a registry key is controlled by its component. If the component is installed, the registry key's Install action is executed (which may actually remove the key); if the component is removed, the Remove action is executed. If a registry key is not linked to a component, its Install action is executed during installation of your product, and its Remove action when the product is removed.

In addition to the explicit installation and removal actions, registry keys are automatically created if a subkey or value is installed under the key, and removed if they become empty (unless Remove action is set to Do not remove).

Warning Registry key removal warning

Removing a non-empty registry key is potentially a dangerous operation, even more so if its subkeys are also removed. During the removal process, all values under the key (and potentially under its subkeys) are removed regardless of their installation status. This may cause serious problems on the target system. If at all possible, you should selectively remove registry values by using registry value installation and removal actions (see Registry Value).

Attributes

The following attributes and options are available.

Attribute Description
Key name Enter the name of the registry key. You may use symbolic references in the name; they will be resolved when the registry key is installed.
Key alias Enter the alias for the registry key. This alias must be unique in the project. InstallMate uses the alias as if it were a symbolic variable; for example, you can use expressions like <@regkey_alias\value> to retrieve registry value data during installation.
Install action Select the desired installation action from the drop-down list. The installation action is executed when the registry key's component is installed. If the registry key is not linked to a component, the action is executed when the product as a whole is installed. See Installation actions below for the full list of actions.
Remove action Select the desired removal action from the drop-down list. The removal action is executed when the registry key's component is removed. If the registry key is not linked to a component, the action is executed when the product as a whole is removed. See Removal actions below for the full list of actions.
Registry view Select the desired registry view from the drop-down list. See Registry views for an explanation of registry views. The following options are available:
Registry view option 32-bit Windows 64-bit Windows
Existing key, else Native Always uses 32-bit registry Checks 64-bit and 32-bit views (in that order) and uses the first that already contains the key. If neither does, uses the 64-bit registry.
Native only Always uses 32-bit registry Always uses 64-bit registry
64-bit, then 32-bit Always uses 32-bit registry

Tries to use the 64-bit view first, followed by the 32-bit one if the 64-bit failed.

Note: This option differs from Existing key, else Native in that it will not try the 32-bit registry view if the registry action succeeds in the 64-bit view, even if the key already exists in the 32-bit view.

64-bit only Always fails Always uses 64-bit registry
32-bit only Always uses 32-bit registry Always uses 32-bit registry
Keep during updates

Check this box to keep the registry key during updates, i.e., when the uninstaller is run in upgrade mode (TsuUpgrade is nonzero). If this box is checked, the Remove action is ignored during upgrades (only) and the registry key will remain on the target system.

This option is useful if the registry key contains data that must be retained during upgrades of the product, but should be removed during full product uninstallations.

Installation actions

The installer can create or remove the registry key and its values during product installation.

Note: As a side effect, removal of a key may lead to removal of its parent key if the key is empty after the key is removed. This in turn may lead to removal of the grandparent key, etc.

Install action Description
Create on demand The registry key is created, if it does not already exist, when its first value or subkey is installed.
Create always The registry key is created if it does not already exist, regardless of any values or subkeys under it.
Remove if empty If the registry key exists but has no values or subkeys, it is removed. If it contains one or more values or subkeys, it is left as-is.
Remove key and values If the registry key exists, its values (but not subkeys) are removed. If it contains no subkeys, the key itself is then removed. If it does contain one or more subkeys, the registry key is retained (but its values are gone).
Remove key and subkeys If the registry key exists, its values and all of its subkeys are removed recursively, then the key itself is removed.

Removal actions

The installer can remove or retain the registry key during product removal.

Note: As a side effect, removal of a key may lead to removal of its parent key if the key is empty after the key is removed. This in turn may lead to removal of the grandparent key, etc.

Remove action Description
Do not remove The registry key is left as-is.
Remove if empty If the registry key exists but has no values or subkeys, it is removed. If it contains one or more values or subkeys, it is left as-is.
Remove key and values If the registry key exists, its values (but not subkeys) are removed. If it contains no subkeys, the key itself is then removed. If it does contain one or more subkeys, the registry key is retained (but its values are gone).
Remove key and subkeys If the registry key exists, its values and all of its subkeys are removed recursively, then the key itself is removed.

Related topics

Registry, Registry Views, Working with attribute panes