Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wix 如何从注册表项设置TARGETDIR或INSTALLDIR?_Wix - Fatal编程技术网

Wix 如何从注册表项设置TARGETDIR或INSTALLDIR?

Wix 如何从注册表项设置TARGETDIR或INSTALLDIR?,wix,Wix,从上次运行安装程序时在Windows注册表中设置的值设置安装目录时遇到了很大的问题。此选项用于正确默认路径。奇怪的是,我们总是让用户设置安装路径,即使是在升级时,如果它与上次安装时的文件夹不同,那么我们不会为了让用户并行运行应用程序的多个版本而删除现有产品 现在,我一直在网上搜索解决方案,我发现了很多建议,但这些建议都没有影响我的INSTALLDIR,我可以在安装界面中看到它,在那里我可以选择安装位置 我现在得到的是: <Property Id="PREVINSTALLDIR">

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

现在,我一直在网上搜索解决方案,我发现了很多建议,但这些建议都没有影响我的
INSTALLDIR
,我可以在安装界面中看到它,在那里我可以选择安装位置

我现在得到的是:

<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>
退出安装程序时,属性将转储到日志文件中,我看到以下情况:

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


我在这里尝试了很多方法,但无论如何,我都无法更改
TARGETDIR
INSTALLDIR

嗨,我成功地使用以下方法更改了我的
INSTALLLOCATION

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


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

您好,我使用以下方法成功更改了我的
INSTALLLOCATION

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

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

这对我来说很有效:

<!-- 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>

这对我很有用:

<!-- 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>


不幸的是,这没有帮助,它仍然希望安装在同一位置。不幸的是,这没有帮助,它仍然希望安装在同一位置。