Checking for successful uninstall(检查是否成功卸载)
问题描述
我正在尝试自动化安装过程,在该过程中我卸载以前的版本并在顶部安装较新的版本.如果卸载成功,我应该如何测试(在我的引导程序中,用 C# 编码)?
I'm trying to automate an install process in which I uninstall a previous version and install a newer version over the top. How should I test (in my bootstrapper, coded in C#) if the uninstall was a success?
这就是我目前启动卸载的方式.
This is currently how I'm launching the uninstall.
Process p = Process.Start("msiexec", /*various switches*/);
p.WaitForExit();
我目前也在纠结动态多实例,这真的让我心烦意乱,所以在 WiX 本身中处理这个问题即使不是不可能也很困难.
I'm also currently tangling with dynamic multiple instances, which really bend my mind, so handling this problem within WiX itself is difficult if not impossible.
推荐答案
您可以使用 Windows Installer API,而不是通过 msiexec 调用 Windows Installer.您可以通过 P/Invoke、激活 COM 接口或通过 WiX 的 DTF 包装库来做到这一点.用于删除产品的具体功能是 <代码>MsiConfigureProductEx.
Rather than invoke Windows Installer through msiexec, you can use the Windows Installer API. You can do that through P/Invoke, activating the COM interface or via WiX's DTF wrapper library. The specific function to use to remove a product is MsiConfigureProductEx
.
使用 DTF,您可以这样做:
With DTF, you can do it like this:
Installer.SetInternalUI(InstallUIOptions.Silent);
Installer.SetExternalUI(UiHandler, InstallLogModes.Verbose);
Installer.EnableLog(InstallLogModes.None, null);
Installer.ConfigureProduct(productCode, 0, InstallState.Removed, "");
Console.WriteLine("RebootRequired: {0} RebootInitiated: {1}", Installer.RebootRequired, Installer.RebootInitiated);
UiHandler
委托允许应用监控进度.如果有错误,DTF 会抛出异常.
The UiHandler
delegate allows the app to monitor progress. If there is an error, DTF throws an exception.
这篇关于检查是否成功卸载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:检查是否成功卸载


- C#MongoDB使用Builders查找派生对象 2022-09-04
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01