System variables

System variables are strings that replace longer data references.

They already exist defined on the system and you can view them using the “set” command in CMD.

Set Command
Set Command

You can also access them from System Properties\Advanced\Environment Variables.

Environment Variables View
Environment Variables View

Classification:

User variables - found in: HKEY_CURRENT_USER\Environment

System variables - found in:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

The system variables can be used directly in the package, using the reference type [%ENVVAR].

You can also define new variables to be used by the runtime package.

Tables specific to system variables

Environment
Environment Table
Environment Table

Environment Table columns:

Name: The name of the system variable: the system variable is written or deleted depending on the symbols that appear in front of the name -- there is no specific order for these symbols.

Prefix

Description

=

Creates the variable if it does not exist, and sets it to the given value. If the variable already exists, just set it to the given value.

+

Creates the variable if it does not exist, and sets it to the given value. If it already exists, it has no effect on the value of the variable.

-

Deletes the variable when the component is uninstalled. This symbol can be combined with any prefix.

!

Deletes the variable during the component installation. Windows Installer deletes a variable during installation if the name and value of the variable match the entries in the Environment table. If you want to delete a system variable regardless of its value, it is recommended to use the syntax "!", and leave the Value column blank.

*

This prefix is ​​used by Microsoft Windows NT / 2000 to indicate that the name refers to a system variable (not a user). If no asterisk is present, Windows Installer writes the variable as a user variable. Microsoft Windows 95/98 ignores the asterisk and adds the variable to the autoexec.bat file. This symbol can be combined with any other prefix. It is recommended that packages installed "per-machine", write only system variables (not user), using the * symbol in the name.

=-

The variable is set at installation and deleted at uninstall. This is normal behavior.

!-

Deletes variables when installing or uninstalling.

=+, !+, !=

These prefixes are not valid.

Value:

  • this column contains the value to be set as a formatted string;
  • if this column is empty, the variable is deleted; if the column is empty and the “-” symbol appears in the name column, the variable is deleted when the component is deleted.
  • to add a new value to an already existing one, the value in this column must end with the prefix “~” and the separation character “;”. ex: [~]; Value
  • to add a new value to an already existing one, the value in this column must begin with the suffix “~”, accompanied by the separate character “;” ex: Value; [~]
  • if the string [~] is not present in this field, the value in this column represents the entire value to be set or deleted.
    • each row contains only one value; values such as Value; Value [~] are not recommended due to unpredictability
    • if the field name has the character “+” as a prefix, then you must use the string [~] in the value column; the two must be used together

Environment: - the key that uniquely identifies the record

Component: - a foreign key from the first column of the Component table; this column controls the installation of the system variable through the component

The environment variables can be easily managed in Advanced Installer in the Environment Variables Page.