我使用WiX 3.6构建了一个针对单台计算机的安装程序,以安装我没有开发的软件。不幸的是,在执行过程中,该软件会在HKCU下创建一些注册表键。
在卸载时,这些自创的键也应该被删除。但似乎不太容易删除这些键。我正在与ICE57和/或ICE38进行“斗争”。它们都抱怨perUser和perMachine数据的混合。
希望您可以指导我解决此问题的正确方向。
为了克服ICEs,您应该将每个用户注册表移动到单独的组件中,并使用一些注册表项作为该组件的keyPath,例如:
<Component Id='PerUserRegistry' Guid='*'>
<RegistryValue Id="PerUserRegistry_KeyPAth" KeyPath="yes" Root="HKCU" Key="Software\[Manufacturer]\[ProductName]\[ProductCode]\PerUserRegistry" Name="[PackageCode]" Value="[ProductVersion]" Type="string" />
<!--Other Per-user registry goes here-->
</Component>
我完全同意Christopher的观点:在卸载时保留每个用户的数据是常见做法,但如果需要删除,则Active Setup是唯一可行的选择。
首先,我建议您在安装或重新安装时删除它们,而不是在卸载时删除它们,您只需要添加RemoveRegistry条目和Active Setup,即使用此WiX代码:
<Component Id='ActiveSetup' Guid='*'>
<RegistryValue Id="ActiveSetup00" Root="HKLM" KeyPath="yes" Key="SOFTWARE\SOFTWARE\Microsoft\Active Setup\Installed Components\[PackageCode]\" Name="StubPath" Value="msiexec /fup [ProductCode] /qb-!" Type="string" />
<RegistryValue Id="ActiveSetup01" Root="HKLM" Key="SOFTWARE\SOFTWARE\Microsoft\Active Setup\Installed Components\[PackageCode]\" Value="[ProductName] [ProductVerion] Configuration" Type="string" />
</Component>
<Component Id='PerUserRegistryCleanup' Guid='*'>
<RegistryValue Id="PerUserRegistry_KeyPath" Root="HKCU" KeyPath="yes" Key="SOFTWARE\SOFTWARE\Microsoft\Active Setup\Installed Components\[PackageCode]\" Name="StubPath" Value="msiexec /fup [ProductCode] /qb-!" Type="string" />
<RemoveRegistryKey Id='PerUserRegCleanup' Root='HKCU' Action='removeOnInstall' Key='Key\To\Be\Removed'/>
</Component>
<CustomAction Id="CA_UninstallRegistryCleanUp" Directory="SystemFolder" ExeCommand="REG.exe ADD "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\MySoftName_CleanUp" /v StubPath /d "reg add ^"HKCU\Key\To\Be\Removed^" /va /f" /f" Return="ignore" />
<InstallExecuteSequence>
<Custom Action='CA_UninstallRegistryCleanUp' After='RemoveRegistryValues'>REMOVE~="ALL"</Custom>
</InstallExecuteSequence>
<Component Id='RegCleanup_Remover' Guid='*'>
<RegistryValue Id="PerUserRegistry_KeyPAth" Root="HKLM" KeyPath="yes" Key="SOFTWARE\[Manufacturer]\[ProductName]\[ProductCode]\" Name="DummyKey" Value="[ProductVersion]" Type="string" />
<RemoveRegistryKey Id='RegCleanup_Remover' Root='HKLM' Action='removeOnInstall' Key='SOFTWARE\Microsoft\Active Setup\Installed Components\MySoftName_CleanUp'/>
</Component>
最后注意事项: 在使用所有这些Active Setup的时候要小心Windows终端服务器;并且,一旦为当前的.MSI运行了Active Setup,并且你决定重新安装相同的软件包,它将不会再次运行,除非你更改其PackageConde或在ActiveSetup注册表键下提高版本。这些是另一个时间讨论的主题,如果需要澄清,请告诉我。
而且不要忘记将以上所有组件添加到某个功能中。