尝试使用Singleton

问题描述 投票:-1回答:1

我正在尝试执行IF ProcessExist。

在我的Win 10 64位计算机中,它可以工作,但是当我在其他Windows 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存在,但不存在。

autoit
1个回答
0
投票
#RequireAdmin must be on the very top of your script.

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

关于单例,请参阅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")
© www.soinside.com 2019 - 2024. All rights reserved.