1

UPDATE (2012-02-14): I found out that it's not possible to read environment variables before Install* sequences within CustomActions. This means you cannot read a variable and display it in the UI except you program a exe / dll which returns the variable content... :(

I have created two properties to read the two user defined environment variables %MY_ENV_VAR1% and %MY_ENV_VAR2%. The definition goes like this:

<Property Id="ENV_MYENVVAR1" Value="0"/>
<Property Id="ENV_MYENVVAR2" Value="0"/>

Afterwards I created two custom actions being executed in the UI sequence after the WelcomeDlg:

<CustomAction Id="GET_MYENVVAR1" Impersonate="yes" Return="check" Execute="immediate" Property="ENV_MYENVVAR1" Value="[%MY_ENV_VAR1]"/>
<CustomAction Id="GET_MYENVVAR2" Impersonate="yes" Return="check" Execute="immediate" Property="ENV_MYENVVAR2" Value="[%MY_ENV_VAR2]"/>
<InstallUISequence>
  <Custom Action="GET_MYENVVAR1" After="WelcomeDlg">1</Custom>
  <Custom Action="GET_MYENVVAR2" After="GET_MYENVVAR1">1</Custom>
</InstallUISequence>

The problem I face is, that the environment variables are not read within the defined custom actions. My UI always displays "0" in the respective text fields. Here is the code for the two controls I use:

<Control Id="Control_EnvVar1" Property="ENV_MYENVVAR1" Type="Edit" X="35" Y="191" Width="240" Height="17"/>
<Control Id="Control_EnvVar2" Property="ENV_MYENVVAR2" Type="Edit" X="35" Y="106" Width="240" Height="17"/>

I am using WiX 3.5.2519.0 and MSI 2.0 as basis for my setup program. The installer is running under Win 7 (x64) Professional incl. SP1, .NET Frameworks version from 2.0 to 4.0 are installed as well and the Windows Installer version is 5.0.

Any help would be really appreciated. Thanks! -moik

moik
  • 165
  • 5
  • 14
  • possible duplicate of [Get an environment variable into a WIX property](http://stackoverflow.com/questions/3459998/get-an-environment-variable-into-a-wix-property) – Wim Coenen Feb 09 '12 at 13:22
  • Create an installation log for details. http://stackoverflow.com/questions/7126077/create-an-msi-log-file – Ciprian Feb 09 '12 at 13:30
  • reading environment variables from the registry solved my problem. it seems that "[%USERPROFILE]" will work after first InstallExecute sequence only. poor! – moik Feb 23 '12 at 12:37
  • It might actually only be available after CostFinalize. Once that standard action completes, you likely have access to all the windows environment variables. – jbudreau Nov 11 '14 at 14:50

0 Answers0