如果应用程序打开并且用户想要卸载它,如何添加警告消息 [英] How to add a warning message if app is open and user want to uninstall it

查看:36
本文介绍了如果应用程序打开并且用户想要卸载它,如何添加警告消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个引导程序 EXE 文件,该文件将 .Net 先决条件和我的 MSI 链接在一起.我可以使用此 EXE 成功安装/卸载.

I created a bootstrapper EXE file which have .Net prerequisite and my MSI chained together. I am able to install/uninstall successfully using this EXE.

现在客户想要一个条件,如果应用程序打开并且用户尝试卸载它,他应该看到警告消息.是否可以使用标准引导程序来完成这项工作,或者我应该编写自定义 BA.如果自定义是唯一的解决方案,我真的不知道我应该为此编写哪个条件和代码.任何灯都会有很大帮助.

Now customer wants a condition where he should see a warning message if app is open and user trying to uninstall it. Is it possible to do this job with standardBootstrapper or I should write custom BA. I really dont know which condition and code I should write for this if custom is the only solution. Any lights in this will be a great help.

推荐答案

如果您使用标准引导程序,最好的方法是向您的 msi 添加自定义操作.只需添加属性(例如 IsRunning='0' ),以及在程序运行时使用自定义操作更改它.

If you're using standard bootstrapper the best way is to add custom action to your msi. Just add property (for example IsRunning='0' ), and change it using custom action when program is running.

[CustomAction]
public static ActionResult CustomAction(Session session)
{
     if (Process.GetProcessesByName("process_name").Length > 0)
     {
        session["IsRunning"] = 1;
     }
     return ActionResult.Success;
}

参见 此答案 以了解有关自定义操作的更多信息.而这里是 卸载自定义操作示例

See this answer for more info about custom actions. And here's uninstall custom action sample

然后将对话框添加到 根据该属性显示.

如果您使用的是自定义引导程序,则只需添加该检查在运行 msi 或显示 UI 之前添加到您的代码

If you are using custom bootstrapper, you can just add that check to your code before your msi will be run, or before you'll show UI

这篇关于如果应用程序打开并且用户想要卸载它,如何添加警告消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆