本文介绍了检查卸载成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自动在我卸载previous版本的安装程序并安装更新的版本在上面。我应该如何测试(在我的引导程序,$ C $在C#CD)如果卸载是成功的?

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.

推荐答案

而不是通过MSIEXEC调用Windows安装程序,您可以使用Windows安装程序API。你可以通过P /调用,激活COM接口或通过维克斯的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.

这篇关于检查卸载成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 16:07