为什么函数 "if ProcessExist" 在其他计算机上不起作用

Why Function "if ProcessExist" Don't Work in Others Computers

我正在尝试执行 IF ProcessExist。

在我的 win 10 64 位电脑上它可以工作,但是当我在其他 PC 上用 win 7 甚至 win 10 执行时。它不执行。

 #AutoIt3Wrapper_UseX64=N
    If ProcessExists ("program.exe") Then
MsgBox ("", "Hold", "Test", 10)
    Exit
    Else
        #RequireAdmin
    Run(@ComSpec & " /c " & "C:\folder\file.bat", "", @SW_HIDE)
        EndIf

继续获取好像 program.exe 存在,但它不存在。

#RequireAdmin must be on the very top of your script.

我假设它在您编译可执行文件时不起作用。它可能叫做 program.exe,它正在寻找自己的进程。

关于 Singleton,请参阅 this

_Singleton ( $sOccurrenceName [, $iFlag = 0] )
Enforce a design paradigm where only one instance of the script may be running

示例

#include <Misc.au3>
#include <MsgBoxConstants.au3>

If _Singleton("test", 1) = 0 Then
    MsgBox($MB_SYSTEMMODAL, "Warning", "An occurrence of test is already running")
    Exit
EndIf
MsgBox($MB_SYSTEMMODAL, "OK", "the first occurrence of test is running")