Set Environment Variable does not work

Got a problem you cannot solve? Try here.
InstallAware@Jelich.info
Posts: 41
Joined: Mon Apr 13, 2009 8:58 am

Set Environment Variable does not work

Postby InstallAware@Jelich.info » Fri Feb 12, 2016 4:28 am

Hi Support Team,

my MSI script contains the following command:

~InstallAware Clipboard Data~
~Set Environment~
~{2319A370-12EC-4DE9-99AA-DD08C2C8ED4D}~
~MY_ROOT~
~$TARGETDIR$~
~0~
~2~
~TRUE~
~TRUE~

After Setup has finished I open a command prompt (cmd.exe) and enter 'set'. MY_ROOT is not listed.
When I run cmd elevated it is.
After restart the environment variable MY_ROOT is also visible to non elevated processes.

I assume that something like a change notification is missing, because after a manual change of the System variable MY_ROOT via windows the variable is visible to non elevated processes without the Need for a reboot.

Best regards
Michael

InstallAware@Jelich.info
Posts: 41
Joined: Mon Apr 13, 2009 8:58 am

Re: Set Environment Variable does not work

Postby InstallAware@Jelich.info » Fri Feb 12, 2016 6:01 am

FYI: I work around this by invoking the following API call at the end of my script:

SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, Integer(PChar('Environment')));

FrancescoT
Site Admin
Posts: 5360
Joined: Sun Aug 22, 2010 4:28 am

Re: Set Environment Variable does not work

Postby FrancescoT » Fri Feb 12, 2016 1:20 pm

Dear Michael,

yes, this can be a possible workaround in your case ... otherwise in other circumstances, it may be necessary a system restart.

You may find interesting a similar discussion I had some time ago.
http://www.installaware.com/forum/viewtopic.php?f=2&t=9515

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

InstallAware@Jelich.info
Posts: 41
Joined: Mon Apr 13, 2009 8:58 am

Re: Set Environment Variable does not work

Postby InstallAware@Jelich.info » Fri Feb 12, 2016 2:05 pm

Hi Francesco,

Obviously other users suffer from the same issue.

I've created a DLL with two exported functions. They are called WITHOUT admin rights ('non elevated' by means of "Run Program under UAC") in the Finish Setup Region.

The first one (the already mentioned SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, Integer(PChar('Environment')));) makes the Environment changes immediately effective.

The second one (Delphi code: SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);) repairs the Icon Cache to work arould the problem that replaced executables with a different / changed icon keep show the old icon (e.g. in desktop links).

From my point of view the IA Setup should invoke this commands itself (the latter one probably only in case environment variables has been set during setup/uninstall) to ensure a proper configuration without the need to reboot / relogin.

This way you can get rid of this issue forever...

Best regards
Michael


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 39 guests