0

从我上次运行安装程序时设置的 Windows 注册表中的值设置安装目录时,我遇到了很大的问题。这可以正确默认路径。奇怪的是,我们总是让用户设置安装路径,即使在升级时,如果它与上次安装的文件夹不同,那么我们不会RemoveExistingProducts为了让用户运行应用程序的多个版本而这样做并排。

现在,我一直在网上搜索解决方案,并找到了很多建议,但这些建议都没有真正影响我INSTALLDIR,我可以在设置 UI 中看到这些建议,我可以在其中选择安装位置。

这是我目前得到的:

<Property Id="PREVINSTALLDIR">
   <RegistrySearch Id="PrevInstallDir" 
                   Root="HKCU" 
                   Key="Software\MyCompany\MyApp" 
                   Name="InstallDir" 
                   Type="raw" />
</Property>

<CustomAction Id="SetTargetDir" Property="TARGETDIR" 
              Value="[PREVINSTALLDIR]" 
              Execute="firstSequence" />

<InstallExecuteSequence>
   <Custom Action="SetTargetDir" Before="CostFinalize"></Custom>
   <RemoveExistingProducts After="InstallFinalize">PREVINSTALLDIR ~= INSTALLDIR</RemoveExistingProducts>
</InstallExecuteSequence>

谁能发现我在这里做错了什么?

PREVINSTALLDIR请注意,已阅读RemoveExistingProducts 部分的工作原理。在设置日志中,我还可以看到:

Action start 13:50:27: AppSearch. 
AppSearch: Property: PREVINSTALLDIR, Signature: PrevInstallDir 
Action ended 13:50:27: AppSearch. Return value 1. 

退出设置时,属性被转储到日志文件中,我看到:

Property(C): PREVINSTALLDIR = C:\Some\Path\MyApp 
Property(C): TARGETDIR = C:\ 
Property(C): MyAppDir = C:\ProgramData\Microsoft\Windows\Start Menu\Programs\MyApp\ 
Property(C): INSTALLDIR = C:\Program Files (x86)\MiTek\MyApp\ 

INSTALLDIR不受我上面的 wix 脚本的影响,我TARGETDIR认为也不会受到影响C:\Some\Path\MyApp

我在这里尝试了很多东西,但无论如何我无法做出TARGETDIRINSTALLDIR改变。

4

2 回答 2

3

这对我有用:

<!-- Existing install path -->
<Property Id="EXISTINGINSTALLDIR" Secure="yes">
    <RegistrySearch Id="Locate_EXISTINGINSTALLDIR" Root="HKCU" Key="Software\$(var.CompanyName)\$(var.ProductName)" Name="InstallDir" Type="directory" />
</Property>

<!-- custom action specification -->
<CustomAction Id="Set_INSTALLDIR" Execute="firstSequence" Property="INSTALLDIR" Value="[EXISTINGINSTALLDIR]" />

<InstallExecuteSequence>
    <Custom Action="Set_INSTALLDIR" After="FileCost"><![CDATA[NOT Installed AND (NOT INSTALLDIR) AND EXISTINGINSTALLDIR]]></Custom>
</InstallExecuteSequence>

<InstallUISequence>
  <Custom Action="Set_INSTALLDIR" After="FileCost"><![CDATA[NOT Installed AND (NOT INSTALLDIR) AND EXISTINGINSTALLDIR]]></Custom>
</InstallUISequence>
于 2012-10-08T07:49:07.150 回答
1

嗨,我设法INSTALLLOCATION使用以下方法进行了更改:

<SetDirectory Id="INSTALLLOCATION" Value="[$(var.PlatformProgramFilesFolder)]\[$(var.Manufacturer)]\[ProductName]" Sequence="both"></SetDirectory>

Value必须是完整路径..希望这有帮助..:)

于 2012-09-25T09:46:10.363 回答