Wix 自定义操作以删除使用 INF 文件安装的旧版本
我正在开发一个使用 WIX 安装应用程序的项目。要求之一是在安装当前版本之前删除旧版本。旧版本不是基于MSI的,它是使用SetupApi(依赖于inf文件)创建的。
我认为这可以通过自定义操作来实现,逻辑如下:
- 在 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%NAME% 中查找“古代”版本并提取UninstallString 值(如果可能)
- 如果设置了该值,则运行将执行该命令的自定义操作,通常它是一个字符串,如 RunDll32 advpack.dll,LaunchINFSection C:\PROGRA~1\PROGRAM\file.inf, DefaultUninstall
- 此操作必须在安装程序之前执行,因为它们具有共享文件和注册表项。如果在 MSI 安装结束时执行自定义操作,则会破坏程序
我的问题是:
- 这是删除旧的基于 INF 的程序的推荐方法吗?
有没有办法静默卸载基于 INF 的程序?否则用户体验会很糟糕——一个人正在安装一个程序,突然看到一个“卸载程序”窗口。这是违反直觉的。[通过在卸载命令中添加“,3”来解决]
如果您感兴趣,这里是执行我上面描述的代码片段:
<Property Id="ANCIENTVERSION">
<RegistrySearch Id="RegistrySearchAncientVersion" Type="raw"
Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Program"
Name="UninstallString" />
</Property>
<CustomAction Id="removeAncientVersion"
Directory="SystemFolder"
<!--ExeCommand="[ANCIENTVERSION]" regular uninstall-->
ExeCommand="[ANCIENTVERSION],3" <!--silent uninstall-->
Execute="immediate"
Return="check"/>
<InstallExecuteSequence>
<Custom Action='removeAncientVersion' After='InstallValidate'>ANCIENTVERSION</Custom>
</InstallExecuteSequence>
I am working on a project that uses WIX to install an application. One of the requirements is to remove the old version before installing the current one. The old version is not MSI-based, it is created with SetupApi (which relies on inf files).
I figured this can be achieved with a custom action, the logic is as follows:
- look for the "ancient" version in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%NAME% and extract the UninstallString value if possible
- If the value is set, run a custom action that will execute that command, usually it is a string like RunDll32 advpack.dll,LaunchINFSection C:\PROGRA~1\PROGRAM\file.inf, DefaultUninstall
- This action must be executed before installing the program, because they have shared files and registry keys. If the custom action is executed at the end of the MSI installation, it will break the program
My questions are:
- Is this the recommended way of removing old, INF-based programs?
Is there a way to uninstall INF-based programs silently? Otherwise the user experience will be pretty bad - a person is installing a program, and suddenly they see an "uninstalling program" window. This is counter intuitive.[resolved by adding ",3" to the uninstall command]
In case you're interested, here are the code snippets that do what I described above:
<Property Id="ANCIENTVERSION">
<RegistrySearch Id="RegistrySearchAncientVersion" Type="raw"
Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Program"
Name="UninstallString" />
</Property>
<CustomAction Id="removeAncientVersion"
Directory="SystemFolder"
<!--ExeCommand="[ANCIENTVERSION]" regular uninstall-->
ExeCommand="[ANCIENTVERSION],3" <!--silent uninstall-->
Execute="immediate"
Return="check"/>
<InstallExecuteSequence>
<Custom Action='removeAncientVersion' After='InstallValidate'>ANCIENTVERSION</Custom>
</InstallExecuteSequence>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一番研究,我发现为了运行静默卸载,需要在 UninstallString 命令行末尾添加“,3”。我测试了它,它有效:
定期卸载
静默卸载
至于第一个问题 - 由于卸载机制相当于在“添加/删除程序”中单击“卸载”,我相信它不会比这更干净/更好。
After some research I found that in order to run a silent uninstall, one needs to add ",3" to the end of the UninstallString command line. I tested it and it works:
Regular uninstall
Silent uninstall
As for the first question - since the uninstallation mechanism is the equivalent of clicking "Uninstall" in Add/Remove programs, I believe it can't get any cleaner/better than that.