Wix安装位置

时间:2016-07-12 11:35:23

标签: wix install uninstall custom-action

我有一个WIX设置,允许用户选择安装位置。卸载时,我需要运行应该在安装位置激活文件的自定义操作。我尝试从session["INSTALLDIR"]获取安装位置,但它会产生默认路径,而不是用户提供的路径。

如何到达该位置?

2 个答案:

答案 0 :(得分:1)

如果您希望以后安装INSTALLDIR,例如卸载,则应使用下面链接中描述的记住属性模式。

"根本问题是Windows Installer不会为您保存属性值。这意味着如果用户在安装UI中输入值或在命令行上传递它们,则在修复,升级或卸载期间将不会显示这些值。"

http://robmensching.com/blog/posts/2010/5/2/the-wix-toolsets-remember-property-pattern/

答案 1 :(得分:1)

我已经在我自己的安装程序中完成了这项工作 - 以下内容应该有效。

这会添加一个属性以从注册表中检索安装位置值。

<Property Id="INSTALLDIR">
    <RegistrySearch Id='Registry' Type='raw' Root='HKCU' Key='Software\$(var.Manufacturer)\$(var.ProductName)' Name='Location' />
</Property>

这会在注册表中设置安装位置。

<Component Id="Registry" Guid="*">
    <RegistryKey Root="HKCU" Key="Software\$(var.Manufacturer)\$(var.ProductName)">
        <RegistryValue Name="Location" 
                       Type="string" 
                       Value="[INSTALLDIR]" 
                       Action="write" 
                       KeyPath="yes" />
    </RegistryKey>
    <util:RemoveFolderEx On="uninstall" Property="INSTALLDIR" />