How to use the value of ProgramFilesFolder in a variable in a wxi file

In my wxi file, I want to set a variable that has a Program Files directory. I want him to select the localized value of Program Files.

<?define MyDirectory="!(wix.LocalizedProgramFilesFolder)\MyFiles"?> 

I defined LocalizedProgramFilesFolder as:

 <WixVariable Id="LocalizedProgramFilesFolder" Value="[ProgramFilesFolder]"/> 

However, during installation, MyDirectoryis is selected as:

 "[ProgramFilesFolder]\MyFiles". 

It does not extend ProgramFilesFolder. How to use the value of ProgramFilesFolder in a variable in my wxi file?

+8
wix
source share
1 answer

Not sure why you are using the MyDirectory variable. As WixVariable docs say:

WiX variables are not saved in the msi / msm / pcp file, so they cannot be used when installing the MSI file; This is the concept of WiX.

Its value is written as text in the place where you use it. So, if you want the value to be replaced at the time of installation, you should use it only in that context.

A typical use of ProgramFilesFolder is the / @ Id directory, which can have a MyFiles directory, such as MyFiles . Note. The / @ Id directory is also a property, so it can be used as such.

  <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder"> <Directory Id="INSTALLFOLDER" Name="MyFiles" /> </Directory> </Directory> 

INSTALLFOLDER used instead of MyDirectory . You can use whatever you want, but by default from the project template. These are all caps that makes it publicly available. The value of the public property can be passed to the installer sequence from the user interface or using msiexec or other programs such as boot files.

+7
source share

All Articles