viewpoint-particle

Author Topic: Best way to know when a second Winbatch routine is finished  (Read 268 times)

mjwillyone

  • Newbie
  • *
  • Posts: 49
Best way to know when a second Winbatch routine is finished
« 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

stanl

  • Pundit
  • *****
  • Posts: 1572
Re: Best way to know when a second Winbatch routine is finished
« Reply #1 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.

JTaylor

  • Pundit
  • *****
  • Posts: 1743
    • Data & Stuff Inc.
Re: Best way to know when a second Winbatch routine is finished
« Reply #2 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

limnos

  • Newbie
  • *
  • Posts: 21
Re: Best way to know when a second Winbatch routine is finished
« Reply #3 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

mjwillyone

  • Newbie
  • *
  • Posts: 49
Re: Best way to know when a second Winbatch routine is finished
« Reply #4 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.

td

  • Tech Support
  • *****
  • Posts: 3947
    • WinBatch
Re: Best way to know when a second Winbatch routine is finished
« Reply #5 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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

mjwillyone

  • Newbie
  • *
  • Posts: 49
Re: Best way to know when a second Winbatch routine is finished
« Reply #6 on: August 05, 2021, 01:57:33 pm »
Thank you very much!  I will try your ideas!