且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何确定执行InnoSetup安装脚本之前是否正在运行应用程序

更新时间:2023-11-14 18:13:10

脚本中是否存在可能导致误报的错误?

Is there an error in the script that may give false positives?

没有错误.

您是否知道tasklist可能不可用?考虑一下"XP Home"(是的,它正在逐渐消失),但仍在使用,并且您的解决方案在那儿将无法使用,因为tasklist根本不可用.

Are you aware, that tasklist might not be available? Think of "XP Home" (yes, it's fading out), but still in use and your solution will not work there, because tasklist is simply not available.

还是有比任务列表"更好的方法来确定应用程序是否正在运行?

Or is there a better way to determine if the app is running than 'tasklist'?

是的,还有其他一些也许更可靠的方法可以做到这一点.例如,在安装程序中包含psvince并将其用于过程检测是很常见的.很好的也是基于WMI的解决方案.

Yes, there are some other and maybe more reliable ways to do this. For instance, it's quite common to include psvince in the installer and use it for process detection. Quite nice is also the WMI based solution.

以下是使用InnoSetup进行过程检测"的一些方法:

Here are some approaches for "process detection" with InnoSetup:

  • AppMutex - http://www.jrsoftware.org/ishelp/index.php?topic=setup_appmutex
  • PSVince http://www.vincenzo.net/isxkb/index.php?title=PSVince
  • PSVince Fork https://github.com/XhmikosR/psvince
  • without external DLL https://raw.githubusercontent.com/git-for-windows/build-extra/master/installer/modules.inc.iss
  • WMI + Win32_Process https://***.com/a/9950718/1163786 + https://***.com/a/25518046/1163786
  • ProcessViewer https://github.com/lextm/processviewer