我有以下Wix文件在64位系统的程序文件(x86)中安装文件,在32位系统中安装程序文件。在程序中,我需要访问Installed文件夹中的文件 lpa.config ,该文件可能是以上两个文件之一。为此,我需要在Registry中编写Installed文件夹。有没有办法在Wix中获取Installed文件夹位置?
<?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>
答案 0 :(得分:1)
是的,从WiX文档示例开始:
<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基于Windows Installer,注册表值为Formatted properties,您可以使用熟悉的语法来访问属性:
<RegistryValue Type="string" Name="SetupPath" Value="[INSTALLFOLDER]"/>
在您的情况下,属性名称与<Directory>
元素ID匹配:<Directory Id="INSTALLFOLDER"
。
还有其他方法可以做到这一点,但...... IMO这是最简单的方法。