为什么“如果ProcessExist”功能在其他计算机上不起作用

时间:2019-10-11 20:55:29

标签: autoit

我正在尝试执行IF ProcessExist。

在我的win 10 64位计算机上它可以工作,但是当我在另一台具有win 7或什至具有win 10的PC上执行时,它不会执行。

 #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的提示,但事实并非如此。

1 个答案:

答案 0 :(得分:0)

#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")