我有一个默认的安装目录:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="$(var.Manufacturer) $(var.ProductName)"></Directory>
</Directory>
</Directory>
在安装过程中,我允许用户更改目录。如果用户在主要升级期间确实更改了目录,是否必须手动检索目录并使用实际路径设置INSTALLFOLDER
,或者有办法以某种方式自动检测它吗?
答案 0 :(得分:0)
Windows Installer不直接支持此功能;我想你正在寻找"remember property" pattern。策略是:
INSTALLFOLDER
的值保存到知名位置的注册表中。创作如下:
<!-- Retrieve the property from the registry during AppSearch -->
<Property Id='REMEMBERME'>
<RegistrySearch Id='RememberProperty'
Root='HKCU'
Key='SOFTWARE\My Company\My App'
Name='Remembered'
Type='raw' />
</Property>
<!-- Save the value in the registry for future upgrades -->
<Component Directory='INSTALLFOLDER'>
<RegistryValue Root='HKCU'
Key='SOFTWARE\My Company\My App'
Name='Remembered'
Value='[REMEMBERME]'
Type='string' />
</Component>
Rob Mensching's blog post更详细地描述了这一点。