Search code examples
autoit

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


I'm trying to execute an IF ProcessExist.

in my win 10 64bit computer it works, but when i execute in other PC with win 7 or even with win 10. It do not execute.

 #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

Keep getting as if program.exe exist, but it's not.


Solution

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

    I assume it's not working when you compile the executable. It's probably called program.exe and it's finding its own process.

    As for the Singleton see this:

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

    Example

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