Jump to content

Recommended Posts

Posted

Hi guys

 

If I have a script named "test.exe" running, and while it's running the script "test.exe" will run a new instance, how can I make sure that the second instance waits for the existing instance to finish?

I guess that I should use _Singleton ? But I can only find examples that kills the second instance, instead of waiting for the existing instance, and then run.

Thanks!

David

  • Solution
Posted

You can add this kind of code at the begining of your script :

While ProcessList(@ScriptName)[0][0] > 1
WEnd

; And then your code...
MsgBox(0, "", "Hello")

Compile and run it twice, you will see the 2nd script waits until the first one does not exist

Posted (edited)
#include <_SingleScript.au3> ;https://www.autoitscript.com/forum/topic/178681-_singlescript-assure-that-only-one-script-with-the-same-name-is-running

_SingleScript(1)

MsgBox(64+262144, Default, "Press OK to exit",0)

This one checks for au3 and exe

Edited by Exit
point to new #include location

App: Au3toCmd              UDF: _SingleScript()                             

Posted

Nice one jguinch that's much simpler, I just spent a couple of minutes trying to figure this out.

While 3
    $aList = ProcessList("Test.exe")
    If $aList[0][0] = 0 Then ExitLoop
    If $aList[0][0] > 1 Then
        Sleep(333)
        ContinueLoop
    Else
        ExitLoop
    EndIf
WEnd

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...