WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: mjwillyone on August 02, 2021, 12:25:15 PM

Title: Best way to know when a second Winbatch routine is finished
Post by: mjwillyone on August 02, 2021, 12:25:15 PM
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
Title: Re: Best way to know when a second Winbatch routine is finished
Post by: stanl on August 02, 2021, 02:24:10 PM
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.
Title: Re: Best way to know when a second Winbatch routine is finished
Post by: JTaylor on August 02, 2021, 04:52:17 PM
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
Title: Re: Best way to know when a second Winbatch routine is finished
Post by: limnos on August 03, 2021, 07:11:30 AM
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
Title: Re: Best way to know when a second Winbatch routine is finished
Post by: mjwillyone on August 04, 2021, 01:17:41 PM
Thank you, all.  Actually, I have not compiled the scripts.  They remain .wbt files and I would like to keep them that way.
Title: Re: Best way to know when a second Winbatch routine is finished
Post by: td on August 04, 2021, 02:27:07 PM
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.
Title: Re: Best way to know when a second Winbatch routine is finished
Post by: mjwillyone on August 05, 2021, 01:57:33 PM
Thank you very much!  I will try your ideas!