Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Refresh environment variables from installer without reboot


3 replies to this topic

saveshodhan

saveshodhan
  • Full Members
  • 2 posts

Posted 03 June 2014 - 11:59

Hello everyone,

I am creating a basic MSI type installer in InstallShield 2011, in which I am appending few values to the PATH variable from the installer. I have observed that normally a reboot or a logoff-logon is required for those changes to reflect. But, in order to avoid reboot, I wrote an InstallScript custom action with the following code:

 

///////////////////////////////////////////////////////////////////////////
function MyFunction(hMSI)
#define ENV "Environment"
STRING tmp;
WPOINTER param;
 
begin
 
tmp = ENV;
param = &tmp;
SendMessage(0xFFFF, 0x001A, 0, param);
 
end;

///////////////////////////////////////////////////////////////////////////

 

The details of this Custom Action are:

Synchronous (Check Exit Code)

Immediate Execution

Install Exec Sequence: After InstallFinalize

Install Exec Condition: NOT Installed AND NOT PATCH

 

It works fine on Win7, but when I try to install it on WinXP SP3, the installation hangs on this custom action step.

 

What is it that I am doing wrong? Or what changes need to be done?

Any help would be much appreciated.

 

Thanks,

Shodhan



deramor

deramor
  • Full Members
  • 187 posts

Posted 04 June 2014 - 16:57

Minus some #defines, I am doing the exact same thing in an installscript function for my installscrip msi projects.  Have you tried to not check the exit code on the CA?



saveshodhan

saveshodhan
  • Full Members
  • 2 posts

Posted 05 June 2014 - 05:34

I haven't tried that.. I will..
Btw, will it make a difference that you are using an InstallScript MSI and mine is a Basic MSI ?

Also, is it that I should put the Installscript custom actions in between InstallInitialize and InstallFinalize?

 

One more observation - even though the installation hangs, I can see the product's entry in ARP.

 

As I was short on time, I used this VBScript code:

 

/////////////////////////////////////////////////////////////////////////////////////////
Dim sEnv
Set WshShell = CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
sEnv = WshSysEnv("PATH")
WshSysEnv("PATH") = sEnv
/////////////////////////////////////////////////////////////////////////////////////////
 
Quite simple, and it works..  :)

Edited by saveshodhan, 05 June 2014 - 05:43.


deramor

deramor
  • Full Members
  • 187 posts

Posted 05 June 2014 - 19:04

The only difference I am aware of between the 2 projects that would effect this is the scheduling of a Custom Action vs a function call during OnFirstUIAfter.

I would leave this CA out of the InstallInit and InstallFinalize section.  The reason for this is that during an install, this section first gets parsed once and each step is added to some kind of internal script.  This is intended to be some kind of integrity check.  Then the script is actually executed.  Since the script is only useful after system changes are complete, it is much easier to keep this outside that section. 

 

You may also want to put message boxes in with your script.  This will tell you that your CA is firing for one and you can see the commands you are about to run.  Maybe you can narrow it down to the actual line that is hanging which may provide more information.