Archive: interinstaller communication


interinstaller communication
Installer #1: spawns Installer #2 with ExecWait
Installer #2: sets up a system environment variable & add a directory to the system path
Installer #1: how do i reload system environment variables & new path so i can start using the components installed by Installer #2?

thanks for your time...


Since it might require a reboot (Windows 9x) and I have no idea how to reload the environment variables for a running process on Windows NT, I suggest you write the value it sets to a known registry key and read it in installer #1. You can also use an INI file or a normal file.


you are right, however i choose to use environment variables because i'm setting them up for the application runtime anyways, so i figured i'd use them in the installer as well.

so here is what i found:
CASE 1:
installer #1 spawns & waits for installer #2
installer #2 sets an environment variable through the famous WriteEnvStr function. the WriteEnvStr function broadcasts a windows message to all windows indicating that the environment has changed
installer #1 responds to this message, reloads the environment & now can SEE the new environment variable.

(side note, even the %PATH% variable is reloaded)

CASE 2:
installer #1 sets the enviroment variable with WriteEnvStr
in this case, the installer does not see the variable. to make it see it, i had to set the environment variable for the current process as well, so the whole code is:

; Set environment variable SYNCVOICE_ANT_HOME
; to the installation directory
Push "SYNCVOICE_ANT_HOME"
Push $INSTDIR\ant
Call WriteEnvStr

; set SYNCVOICE_ANT_HOME for current process
StrCpy $R0 "SYNCVOICE_ANT_HOME"
StrCpy $R1 "$INSTDIR\ant"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i(R0, R1).r0'

Conclusion:
Setting an environment variable with WriteEnvStr does not set the variable for the current process, and from what I could tell, it's a Windows thang! The workaround is to set the environment variable for your current process manually with Kernel32::SetEnvironmentVariableA ().


Case one never worked for me, the first installer never updated. It will also always fail on Windows 9x.

Doesn't case two set the environment variable only to the current process? Isn't it the parent process you want to see the changes?

You can always set the path and write the registry key too.