david1337 Posted March 30, 2015 Share Posted March 30, 2015 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 Link to comment Share on other sites More sharing options...
Solution jguinch Posted March 30, 2015 Solution Share Posted March 30, 2015 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 JohnOne 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Exit Posted March 30, 2015 Share Posted March 30, 2015 (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 March 9, 2019 by Exit point to new #include location App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
JohnOne Posted March 30, 2015 Share Posted March 30, 2015 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. Link to comment Share on other sites More sharing options...
david1337 Posted March 30, 2015 Author Share Posted March 30, 2015 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 Thanks mate, that worked just how I wanted it to! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now