cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
conorhoran
Level 4

Refresh Environment Variables InstallScript

Jump to solution

Hi,

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.
#include "ifx.h"

// 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.
//
///////////////////////////////////////////////////////////////////////////////
function RefreshEnvironment(oExtension)
// To Do: Declare local variables.
begin
// Flush the NT registry to all applications.
szEnv = "Environment";
pEnv = &szEnv;
SendMessage (HWND_BROADCAST, WM_WININICHANGE, 0, pEnv );

end;

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.

Regards,

Conor

Labels (1)
0 Kudos
(1) Solution
fluzzi-csw
Level 3

Hi @conorhoran,
Did you ever find a solution to this problem?

View solution in original post

(3) Replies
fluzzi-csw
Level 3

Hi @conorhoran,
Did you ever find a solution to this problem?

Hi, 

I don't believe I did but the solution we were installing changed completely in the end so the installer I was writing at the time was abandoned. 

Reading through it again it looks like the key piece was to get the installscript code working but I am not knowledgeable enough to debug that. Might be as easy to call an external process to retrieve the new environment variable and feed it back to the specific installer that is looking for it but I'm not sure why I didn't do that at the time. 

If you are stuck with a similar problem I would try that but the forum here is not helpful for all issues we have unfortunately. Maybe support would provide something if contacted directly

0 Kudos

Yeah, both the forum and the documentation are not helpful at all...

I'll throw a couple of hours at it then i'll call support, thanks for your time!