In this blog post we explained how to use Windows’ environment variables in Visual Installer; for example as a part of a file path. You can also create or change values for environment variables in the system during an installation by using a script command in Visual Installer’s scripting language. The name of the command is SETENV and you can use this command to set an environment variable to a specific value. If the environment variable does not exists, it will be created. If it already exists, its value will be updated.
Examples of usage
The example below shows how to use the SETENV command to set an environment variable with the variable name MyVariable to the value MyValue:
// Example 1: Set MyVariable = MyValue
SETENV MyVariable, MyValue
You can also use Visual Installer’s variables (for example %DESTDIR) when you set values. The example below shows how to set an environment variable with the variable name MyAppsFolder to the path %DESTDIR\MyApps:
// Example 2: Set MyAppsFolder = %DESTDIR\MyApps
SETENV MyAppsFolder, %DESTDIR\MyApps
The picture below shows same examples in Visual Installer’s scripting editor: