Refresh Environment Variables InstallScript
I have a Suite installer that installs 3 packages and runs two powershell scripts as events.
The order is somewhat like,
Powershell Event - Set Firewall Rules (working)
Install Python (working)
Install Erlang (working)
Install RabbitMQ (working)
Powershell Event - Configure RabbitMQ (not working)
After a few days on this I have determined that the issue is when I call the final script (OnPackagesConfigured) that it cannot load the newly created ERLANG_HOME environment variable installed during the Erlang package install.
This seems to be because the environment variables are loaded when the Suite installation begins and any child processes of the suite will not refresh the variables regardless of any code in these child processes to do so.
I have tried multiple ways inside the powershell script to do this without doing a text replacement on the file that requires the ERLANG_HOME variable and without scheduling a reboot as they would be last resort.
It seems I need to write an InstallScript function that can refresh the environment variables and pass these to the child processes ideally but I can't get it to work.
Sample of my code below to do this. Note we are using Installshield 2018 Premier and Windows 10 for majority of installs.
// This template script provides the code necessary to build an entry-point
// function to be called in an InstallScript action during a Suite installation.
// File Name: Setup.rul
// Description: InstallShield script
// Include Ifx.h for built-in InstallScript function prototypes and for Suite
// function prototypes.
// The keyword export identifies MyFunction() as an entry-point function.
// The argument it accepts must be an object for a Suite extension interface.
export prototype RefreshEnvironment(OBJECT);
// To Do: Declare global variables, define constants, and prototype user-
// defined and DLL functions here.
// Function: MyFunction
// Purpose: This function will be called by the script engine when
// the Suite engine calls your InstallScript action.
// To Do: Declare local variables.
// Flush the NT registry to all applications.
szEnv = "Environment";
pEnv = &szEnv;
SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, pEnv );
If you could assist me with this function it would be a great help, or at least point me in the right direction.
I have read nearly every answer I could find anyway related to this dating as far back as 2007 but I know there were changes to Installscript in 2010 so I'm not even sure if this code is relevant any more.
Thanks in advance.