The "Path" Command |
This command updates "path like" environment variables. To do this it populates the MSI "Environment" table.
The macro takes these parameters:
The default for this parameter can be set via the DEFAULT_ENVIRON_PATH_ATEND macro. This is initially "Y".
The default for this parameter can be set via the DEFAULT_ENVIRON_SYSTEM macro. This is initially "Y".
This parameter should be passed a comma separated list of one or more of the following values:
The default for this parameter can be set via the DEFAULT_ENVIRON_HOW macro. The initial value is "SET_DURING_INSTALLATION, DELETE_ON_UNINSTALL".
User Logoff or Reboot Required? |
To pick up the changed environment variables the user may need to logoff and logon (user environment variables) or reboot (system environment variables). This is because the variables are per-process and will not normally change until the process is restarted at which time it typically inherits the parent processes environment.
Windows Installer will broadcast the "WM_SETTINGCHANGE" message (lParam set to the string "Environment") to all top level windows so that these processes have the opportunity to update their per-process environment details if they so wish. It is a known Windows "feature" that the SCM (services) doesn't handle this message.
As a diagnostic aid, the "PROCESS EXPLORER" tool can show you the "process hierarchy" as well as each processes environment.
EXAMPLES |
<$Component "Environment" Directory_="<$AnyDir>" LM="Y"> ;--- Test environment macro (create in install, remove in uninstall) ----- <$Environment Name="EnvVarLit" VALUE="Value4EnvVar1"> ;;Assign literal <$Environment Name="EnvVarExp" *VALUE="WeekDayName(WeekDay(date()))"> ;;Assign result of VBSCRIPT expression <$/Component> <$Component "SomeExistingComponentJustAsAnExampleOfHowToDoIt"> ;--- Test PATH macro ----------------------------------------------------- <$Path "C:\Some\Path"> ;;Normally update "PATH" <$Path "[TARGETDIR]"> ;;Refer to MSI directory/property <$Path ".REX" NAME="PATHEXT"> ;;Update another type of "path like" environment <$/Component>
WARNING |
Have a look at the following bugs:
Note that the value will end with a slash, if this causes problems with your program then I'd suggest you fix your program, however if its someone else's then see the "Trailing Slash Removal" section for an example that uses a custom action or perhaps a better way is to use "." (for "current" directory), for example:
<$Path "[INSTALLDIR]." System="N">