Best way to know when a second Winbatch routine is finished

Started by mjwillyone, August 02, 2021, 12:25:15 PM

Previous topic - Next topic

mjwillyone

I have two processes I want to run.  The first is a simple script to check email in an email program.  The second is a far more complex script of hundreds of lines of code.  I would like to know how I can run the second script inside the first but not put them into one .wbt file.  I have my reasons for keeping them as two separate files. The second script may on 1 day take almost no time at all.  On a busy day, it may take 30 minutes or more.  So, I would like the second script to finish then move control back to the first script.

Thank you for helping me with this!

Mike

stanl

Off the top of my head.... you could compile the 2nd script as .wbc and use the call command only when the first script requires... Would mean a dialog with a button or other control... or you could wait for others to respond.

JTaylor

A little uncertain on what you are doing but, assuming some things,  you could simply use #include for your second file and simply call the functions in the order you need.    A slight variation on Stan's suggestion.   You can have code for the same script in many different files, of course.   

Jim

limnos

If both are separate compiled exe's, just run the one from the other, and use a while loop to wait for the one you call to run.

run("second.exe","")
while AppExist ("second.exe")==@true
   timedelay(3)
endwhile

mjwillyone

Thank you, all.  Actually, I have not compiled the scripts.  They remain .wbt files and I would like to keep them that way.

td

You can always use *ShellExecuteWait (assuming you have a recent version of WinBatch) to start WinBatch with your second script's file name.  Assuming you don't have any variable name conflicts and you always want the first script to wait for the second then simply use the Call function to run the second script from the first.

* You can also use RunWait instead when you don't have elevation issues to worry about as is likely here.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

mjwillyone