| Reference information | |
|---|---|
| Project page | Environment Variables |
| Related topics | Working with attribute panes |
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.
Windows Installer requires that all environment variables are linked to components;
Tarma ExpertInstall will issue a BLD:E0072
diagnostic message if this is not the case.
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 and later), environment variables are stored in the registry and do not require a restart.
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, Tarma Installer will install the environment variable for the current user only (i.e., for the installing user).
The installer can create, modify, or remove the environment variable during product installation. The effect of the actions differs somewhat between Tarma Installer and Windows Installer, because Windows Installer does not support the full complement of installation actions.
| Install action | Tarma Installer | Windows Installer |
|---|---|---|
|
Do not install |
The environment variable is not installed. If it is already present on the target system, its value is left unchanged. | Same |
| 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. | Same |
| 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. | Not supported. Behaves as Overwrite existing 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. | Same, except that the separator is also inserted when there is no existing value. |
| 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. | Same, except that the separator is also inserted when there is no existing value. |
| Overwrite existing value | The environment variable is installed and the existing value, if any, is replaced by the new value. | Same |
| 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. | Not supported. Behaves as Remove if matched. |
| Remove if matched | If the environment variable exists, it is removed if, and only if, its existing value matches the specified value. | Same |
| Remove completely | If the environment variable exists, it is removed in its entirety. | Same |
The installer can modify, remove, or retain the environment variable during product removal. The effect of the actions differs somewhat between Tarma Installer and Windows Installer, because Windows Installer does not support the full complement of removal actions.
| Remove action | Tarma Installer | Windows Installer |
|---|---|---|
| Do not remove | The environment variable is left as-is. | Same |
| 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. |
All removal actions depend on the installation action. If the installation action specified Prepend or Append, the partial value is removed; else the entire value is removed. If the resulting value is empty, the 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. | Not supported. Behaves as the other removal actions. |
This pane contains the following attributes and options.
| 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.
|
| Alias | Enter the alias for the environment variable. This alias must be unique in the project; it is used as a key in the Windows Installer database. (Tarma Installer does not currently use the alias, but this may change in future releases.) |
| 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. |
| 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 above 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 above for a full list of actions. |
| 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 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. |