如果检测到进程正在运行,请停止安装 [英] stop installation if detect process is running

查看:338
本文介绍了如果检测到进程正在运行,请停止安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在使用高级安装程序安装新加载项之前检查某个进程是否正在运行。为此,在自定义操作中,选择检测进程,然后放置要停止的进程。这样,我就可以运行或停止AI_PROCESS_STATE。但是,现在我不知道如何停止安装(如果正在运行),或者至少显示一条消息,告诉您有必要在继续安装之前将其关闭。

I want to check if a process is running before installing a new add-in using the advance installer. To make that, in custom Actions, I select detect process and put the process that I want to stop. With that I get AI_PROCESS_STATE Running or Stopped. But now I don't know what to do to stop the installation if it is Running or at least show a message telling that is necessary to close it before continue.

有一些类似显示消息框的选项,但是如果我放它们,它们总是会出现。我不知道如何仅当AI_PROCESS_STATE的值为运行时才显示它们。

There are options like display message box but if I put them they always appear. I don't know how to make them appear only when AI_PROCESS_STATE has the value Running.

推荐答案

这里有几个问题:

执行此操作的一般方法是调用自定义操作Dll,该操作将查找该进程,并在该进程正在运行时设置安装程序属性,那么安装可能会失败使用19类自定义操作和您自己的错误消息。运行进程并不能为您提供一个向安装返回值的好方法,因此您会显示错误消息。

The general way to do this is to call a custom action Dll that looks for the process, and sets an installer property if the process is running, then you can fail the install with a type 19 custom action and your own error message. Running a process doesn't give you a good way to return a value into the install so you can show an error message.

但是,获取进程列表需要提升,默认情况下,您不会在安装开始时就得到提升。

However, getting the list of processes requires elevation, and by default you're not elevated at the start of the install.

您确定没有发明问题吗?用户为什么要关闭进程?用户友好的方法是注册您的加载项,并告诉用户他们可能需要重新启动应用程序,然后才能显示新的加载项。

Are you sure you're not inventing a problem? Why should the user shut down the process? The user-friendly approach is to register your add-in and tell the user they may need to restart the app before their new add-in will show up.

这篇关于如果检测到进程正在运行,请停止安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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