Controlling Environment Variables with Orca
In this article I’m briefing about the operators\symbols which can be used to alter the environment variables during the installation of an MSI package.
Before going to the major point, Lets have a look on the FAQ about environment variables.
What is an Environment variable?
Environment variables are strings that contain information about the environment for the system, and the currently logged on user. Some software programs use the information to determine where to place files (such as temporary files).
What is the difference between System Variable and User Variable?
System Variables
System environment variables are defined by Windows and apply to all computer users. Changes to the system environment are written to the registry, and usually require a restart to become effective. You must need an administrator privilege to modify a system environment variable
The systems variables are stored in the following location in registry.
HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Control\ Session Manager\ Environment
User Variables
Any user can add, modify, or remove a user environment variable. The changes are written to the registry, and are usually effective immediately. However, after a change to user environment variables is made, any open software programs should be restarted to force them to read the new registry values. The common reason to add variables is to provide data that is required for variables that you want to use in scripts.
The User variables are stored in the following location in registry.
HKEY_CURRENT_USER\Environment
Ref :MSDN (http://support.microsoft.com/kb/310519)
Ok, Lets come to the main points...
There are some symbols\operators we can use in Environment table to control the operations(Add,Append,Delete) on environment variable during the installation of an MSI package.
Operations : Respective Symbol\operator
1. Create value when installed =
2. Create value if not present on install +
3 .Delete value on install !
4. Delete value when uninstalled –
5. Set value on install and delete on uninstall =-
Replacement options:
Operations : Respective Symbols
1. Append at the end of current value [~];
2. Insert the beginning of the current value ;[~]
3. Replace current value No symbol
How to easily identify an environment variable is a Uservariable or System variable from Environment table?
System variable will be having * mark before the operators.
Eg: *=-MYVAR is a system variable where as =-MYVAR is a Uservariable.
I hope the above information will be very useful for you while you modify the Environment table with Orca.
Once you open an MSI with Orca , go to environment table and modify the operators in Name tab to alter the environment variable operations during the install. To control append at end use [~]; and for appending at beginning add ;[~] in Value tab in the respective rows of the variable to modify.
Eg: To Append at End
[~];[PersonalFolder]
To append at beginning,
[ProgramFilesfolder];[~]
Eg: