WiX:从RegistySearch设置安装目录会导致错误"无法访问网络位置"

时间:2015-02-21 18:47:57

标签: wix windows-installer wix3.9

我正在制作基于WixUI_Advanced的安装程序。我正在使用此处的解决方案:WiX: How to override "C:\Program Files (x86)" on x64 machine in WixUI_Advanced sequence?

但是,我希望安装程序记住以前的安装目录。尝试设置APPLICATIONFOLDER属性会导致错误"无法访问网络位置"后跟目录名称。只有在注册表中实际找到值时(升级程序时)才会发生这种情况。

以下是相关代码:

<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="$(var.Version)" Manufacturer="OronDF343" UpgradeCode="22187c5e-5fd6-4734-802e-236abd321433">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="$(var.ProductName)" />

<PropertyRef Id="NETFRAMEWORK45" />
<Condition Message="This application requires .NET Framework 4.5.1 or later. Please install .NET Framework version 4.5.1 or higher and then run this installer again.">
  <![CDATA[Installed OR (NETFRAMEWORK45 >= "#378758")]]>
</Condition>

    <MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="A newer version of $(var.GlobalProductName) is already installed." />

<!-- This is where the problem is. This is how it was implemented in the solution linked above, but I have tried it without the SetDirectory. -->
<Property Id="APPLICATIONFOLDER" Secure="yes">
  <RegistrySearch Id="RegistrySearch" Type="raw" Root="HKLM" Win64="$(var.Win64)" Key="Software\$(var.Company)\$(var.ProgID)" Name="InstallLocation" />
</Property>
<SetDirectory Id="APPLICATIONFOLDER" Value="[$(var.PlatformProgramFilesFolder)]$(var.GlobalProductName)">APPLICATIONFOLDER=""</SetDirectory>
<!---->

    <MediaTemplate EmbedCab="yes" />

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="DesktopFolder" Name="Desktop" />
  <Directory Id="$(var.PlatformProgramFilesFolder)">
    <Directory Id="APPLICATIONFOLDER" Name="$(var.GlobalProductName)">
      <Directory Id="skins" Name="skins"/>
    </Directory>
  </Directory>
  <Directory Id="ProgramMenuFolder">
    <Directory Id="ApplicationProgramsFolder" Name="$(var.GlobalProductName)"/>
  </Directory>
</Directory>

<Property Id="ApplicationFolderName" Value="$(var.GlobalProductName)" />
<Property Id="WixAppFolder" Value="WixPerMachineFolder" />
<WixVariable Id="WixUISupportPerUser" Value="0" />
<WixVariable Id="WixUILicenseRtf" Value="gpl-3.0.rtf" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch $(var.GlobalProductName)" />
<Property Id="WixShellExecTarget" Value="[#$(var.Project.TargetFileName)]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

    <Feature Id="ProductFeature" Title="$(var.ProductName) Core Files" Level="1" Absent="disallow">
  <ComponentRef Id="CreateDirectories" />
        <ComponentGroupRef Id="ProductComponents" />
  <ComponentGroupRef Id="RegistryStuff" />
    </Feature>
<UI>
  <UIRef Id="WixUI_Advanced" />
  <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>
<!--Hacks for WixUI_Advanced install folder-->
<CustomAction Id="OverwriteWixSetDefaultPerMachineFolder" Property="WixPerMachineFolder" Value="[APPLICATIONFOLDER]" Execute="immediate" />
<CustomAction Id="SetARPINSTALLLOCATION" Property="ARPINSTALLLOCATION" Value="[APPLICATIONFOLDER]" />
<InstallUISequence>
  <Custom Action="OverwriteWixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" />
</InstallUISequence>
<InstallExecuteSequence>
  <Custom Action="OverwriteWixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" />
  <Custom Action="SetARPINSTALLLOCATION" After="InstallValidate"/>
</InstallExecuteSequence>
</Product>

编辑:我没有包含保存注册表值的代码,但是它被保存为&#39;&#34; [APPLICATIONFOLDER]&#34;&#39;并删除双引号修复它以进行全新安装。 也忘了SetDirectory中的括号

0 个答案:

没有答案