Environment Variable
An Environment Variable object represents an environment variable for installation or removal. You can add or remove entire variables, or you can append or prepend partial values, for example to add additional paths to the PATH environment variable.
Installation or removal of an environment variable is controlled by its component. If the component is installed, the environment variable's Install action is executed (which may actually remove the variable); if the component is removed, the Remove action is executed. If an environment variable 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.
Note: On Windows 95, 98, and Me, environment variables are added to the AUTOEXEC.BAT file and require a system restart to take effect. This restart is automatically scheduled on these platforms if environment variables are modified. On Windows NT-based platforms (NT4, 2000, XP, 2003, Vista, 2008 and later), environment variables are stored in the registry and do not require a restart.
Attributes
The following attributes and options are available.
Attribute | Description |
---|---|
Name | Enter the name of the environment variable. This name may not contain spaces, tabs, or the '=' character. You may use symbolic references in the name; they will be resolved when the variable is installed. |
Value | Enter the value for the environment variable. You may use symbolic references in the value; they will be resolved when the variable is installed. |
Alias | Enter the alias for the environment variable. This alias must be unique in the project. (InstallMate does not currently use the alias, but this may change in future releases.) |
Install action | Select the desired installation action from the drop-down list. The installation action is executed when the environment variable's component is installed. If the environment variable is not linked to a component, the action is executed when the product as a whole is installed. See Installation actions below for a full list of actions. |
Remove action | Select the desired removal action from the drop-down list. The removal action is executed when the environment variable's component is removed. If the environment variable is not linked to a component, the action is executed when the product as a whole is removed. See Removal actions below for a full list of actions. |
Keep during updates | Check this box to keep the environment variable 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 environment variable will remain on the target system. This option is useful if the environment variable contains data that must be retained during upgrades of the product, but should be removed during full product uninstallations. |
Current User only | Check this box to install the environment variable for the current user only (i.e., the installing user); clear it to install the environment variable for all users. This option only has effect on Windows NT-based platforms (NT4, 2000, XP, 2003 and later); on Windows 95, 98, and Me, all environment variables are system-wide. Furthermore, during a Current User installation (see the Installer options project page), all environment variable are automatically installed for the current user only. |
Separator | Enter the separator character that is used for Append or Prepend installation actions. The default character is a semicolon ';', which is commonly used to separate paths in a path list, but you may choose any character that your application requires. If you leave this field blank, the new value is added to the existing value without separator. |
Current User vs. system-wide variables
On Windows NT-based platforms, environment variables can be installed either for the Current User only or as system-wide variables. Installation of system-wide variables requires Administrator privileges (see Dealing with access rights); if those are not available, InstallMate will install the environment variable for the current user only (i.e., for the installing user).
Installation actions
The installer can create, modify, or remove the environment variable during product installation.
Install action | InstallMate |
---|---|
Do not install |
The environment variable is not installed. If it is already present on the target system, its value is left unchanged. |
Install if not present | The environment variable is only installed if it does not already exist. If it is already present on the target system, its value is left unchanged. |
Install if present | The environment variable is only installed if it already exists. In that case, the existing value is replaced by the new value. |
Prepend to existing value | The environment variable is installed. If it already exists, the new value is prepended to the existing value and the optional separator is inserted between the newly added portion and the existing value. If the variable did not exist, it is created and set to the new value. The separator is not used in that case. Note: If the new value already appears in the environment variable, it is not added again. This is done to prevent duplicates of folders paths etc. in variables such as PATH. |
Append to existing value | The environment variable is installed. If it already exists, the new value is appended to the existing value and the optional separator is inserted between the the existing value and the newly added portion. If the variable did not exist, it is created and set to the new value. The separator is not used in that case. Note: If the new value already appears in the environment variable, it is not added again. This is done to prevent duplicates of folders paths etc. in variables such as PATH. |
Overwrite existing value | The environment variable is installed and the existing value, if any, is replaced by the new value. |
Remove partial value | If the environment variable exists, the portion specified by its new value is removed from the existing value along with the optional separator character. If the resulting value is empty, the environment variable is removed altogether. |
Remove if matched | If the environment variable exists, it is removed if, and only if, its existing value matches the specified value. |
Remove completely | If the environment variable exists, it is removed in its entirety. |
Removal actions
The installer can modify, remove, or retain the environment variable during product removal.
Remove action | InstallMate |
---|---|
Do not remove | The environment variable is left as-is. |
Remove partial value | If the environment variable exists, the portion specified by its new value is removed from the existing value along with the optional separator character. If the resulting value is empty, the environment variable is removed altogether. |
Remove if matched | If the environment variable exists it is removed if, and only if, its existing value matches the specified value. |
Remove completely | If the environment variable exists, it is removed in its entirety. |
Restore original | The value of the environment variable is restored to the value it had before the first installation action. If that value was empty or the variable did not exist at that time, the variable is removed in its entirety. |