Reputation: 1637
I have following Wix File that installs the file in Program Files(x86) for 64 bit system and Program Files in 32 bit system. In the program I need to access the file lpa.config that is present in Installed folder, which may be one of two above. For This I need to write the Installed folder in Registry. Is there any way to get the Installed folder location in Wix?
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="CustomWixInstallerWithCustomAction" Language="1033" Version="1.0.0.0" Manufacturer="LogPoint" UpgradeCode="ba9015b9-027f-4451-adb2-e38f9168a850">
<Package InstallerVersion="200" Compressed="no" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="CustomWixInstallerWithCustomAction" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="CustomWixInstaller" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="SomeRandomEXE">
<File Source ="G:\SarVaGYa\myworkspace\LatestLpa\lpa\lpa_c\here\src\lpa\Release\lpa.exe" />
</Component>
<Component Id="registry_values" Guid="{11FB6C4C-3C90-4F46-B0D2-BB95150F60E6}">
<RegistryValue
KeyPath="yes"
Root="HKCU"
Key="Software\Logpoint"
Value="Here I need the path"
Type="string" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
Upvotes: 1
Views: 3306
Reputation: 67080
Yes, starting from WiX documentation example:
<DirectoryRef Id="TARGETDIR">
<Component Id="RegistryEntries" Guid="PUT-GUID-HERE">
<RegistryKey Root="HKCU"
Key="Software\Microsoft\MyApplicationName"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="string" Name="SetupPath" Value="PUT-PATH-HERE"/>
</RegistryKey>
</Component>
</DirectoryRef>
WiX is based on Windows Installer and Registry values are Formatted properties, you can use familiar syntax to access properties:
<RegistryValue Type="string" Name="SetupPath" Value="[INSTALLFOLDER]"/>
Property name matches your <Directory>
element ID, in your case: <Directory Id="INSTALLFOLDER"
.
There are other ways to do it but...well IMO this is easiest one.
Upvotes: 3