davesh Posted June 9, 2010 Share Posted June 9, 2010 Hi, I am writing a script, and in this script I need to run an executable from the command prompt. I want to pause the execution of the script until the exe is done (it can take between 20sec - 3min) I am using a loop to determine when the exe ends, but for some reason it passes thru the loop once and continues with the script. run("cmd") send("Find_Glitches") send("{ENTER}") do sleep(500); until (wingettitle("[active]") <> "C:\WINDOWS\system32\cmd.exe - Find_Glitches") winclose("C:\WINDOWS\system32\cmd.exe") I know for a fact that I have the correct window title, but for some reason the CMD window is closed before the end of the program. Anyone? p.s I cannot use runwait("Find_Glitches") for some reason the exe does not run properly. Link to comment Share on other sites More sharing options...
JohnOne Posted June 9, 2010 Share Posted June 9, 2010 You will probably be better with something like $PID = run("cmd") send("Find_Glitches") send("{ENTER}") While ProcessExists($PID) Sleep(100) WEnd Although Im no expert on commandline 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...
UEZ Posted June 9, 2010 Share Posted June 9, 2010 (edited) Here an example with Notepad because Find_Glitches I don't know! Should work similar:Run(@WindowsDir & "\Notepad.exe", "", @SW_MAXIMIZE) While Sleep(100) * WinGetTitle("[CLASS:Notepad]", "") WEnd ExitMaybe you can upload Find_Glitches...BR,UEZ Edited June 9, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
omikron48 Posted June 9, 2010 Share Posted June 9, 2010 (edited) You can just use the process ID returned by Run. Global $pID = Run($process) If @error <> 0 Then MsgBox(0x2030, "Error", "Failed to run " & $process & "!") EndIf ProcessWaitClose($pID) EDIT: Wow. A bunch of replies all at once... Edited June 9, 2010 by omikron48 Link to comment Share on other sites More sharing options...
davesh Posted June 9, 2010 Author Share Posted June 9, 2010 Thanks all, but I am still having problems with this. When I use the RunWait command the Find_Glitches program reports that it cannot find a file needed for running. runwait("K:\Users\Dave\Find_Glitches","K:\Users\Dave\") This is because the AutoIt is not running it from the directory where Find_Glitches.exe resides. Any solution? Link to comment Share on other sites More sharing options...
JohnOne Posted June 9, 2010 Share Posted June 9, 2010 Yes Tell it the working directory where the file resides. 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...
davesh Posted June 9, 2010 Author Share Posted June 9, 2010 YesTell it the working directory where the file resides.How do I do this? I added the working directory in the runwait() command. Link to comment Share on other sites More sharing options...
JohnOne Posted June 9, 2010 Share Posted June 9, 2010 (edited) runwait("K:\Users\Dave\Find_Glitches","K:\Users\Dave\")They both look the sameThe second one should be the directory containing the file it cannot find. Edited June 9, 2010 by JohnOne 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...
bo8ster Posted June 10, 2010 Share Posted June 10, 2010 As JohnOne pointed out, you need to specify where working directory which is done in the second param. Think of it as the folder you will cd to before you run the command. Simply doing runwait("K:\Users\Dave\Find_Glitches") will execute the program in the default working directory. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
davesh Posted June 10, 2010 Author Share Posted June 10, 2010 As JohnOne pointed out, you need to specify where working directory which is done in the second param. Think of it as the folder you will cd to before you run the command.Simply doing runwait("K:\Users\Dave\Find_Glitches") will execute the program in the default working directory.But as you can see in the example I gave, I did specify the "working dir" parameter of the Run command, and it is still not working properly. Link to comment Share on other sites More sharing options...
JohnOne Posted June 10, 2010 Share Posted June 10, 2010 Is the file "Find_Glitches.exe" located in "K:\Users\Dave\" ? 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...
bo8ster Posted June 11, 2010 Share Posted June 11, 2010 But as you can see in the example I gave, I did specify the "working dir" parameter of the Run command, and it is still not working properly.Do this. Open a command window, cd to the directory and type 'start Find_Glitches'. When that is done, post the dir you executed the command from. If it does not work from cmd line it will not work within AutoIt. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] 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