Page 1 of 1

Run program with different methods in loops

Posted: 15 May 2021 01:45
by liargof
Hello,

I have a program that needs 3 methods to run in parallel.
Each method takes different time to finish, and then the command line closes. But I need each method to restart after it finishes

Right now I do something like that in my .bat file:

Code: Select all

cd  C:\ProgramFolder\

START program -m method1 //takes 8 hours to finish then the CMD window closes
START program -m method2 //takes 10 hours to finish then the CMD window closes
START program -m method3 //takes 12 hours to finish then the CMD window closes
What I do now is I wait for the last method to end and then I run the .bat again - so there are a few hours where the other 2 methods don't run as they should, but I can't go every 2 hours go restart each one manually.

Is there a way to run each in loop when each of them finishes? Will I need separate .bat files for each method?

Thanks

Re: Run program with different methods in loops

Posted: 15 May 2021 04:59
by aGerman
At least you would need to run 3 cmd.exe processes. They may run all from within the same batch file and they may all run in the same console window. Something about like that:

Code: Select all

@echo off
cd  C:\ProgramFolder\
start /b cmd /c "for /l %%i in () do start /b /wait program -m method1"
start /b cmd /c "for /l %%i in () do start /b /wait program -m method2"
start /b cmd /c "for /l %%i in () do start /b /wait program -m method3"
pause
Steffen

Re: Run program with different methods in loops

Posted: 15 May 2021 06:14
by liargof
Thank you!

If I want to see each method running in separate CMD window, should I remove the "/b" that comes after the "start"?

What I want is that each method will run in loops in its own command window

Re: Run program with different methods in loops

Posted: 15 May 2021 21:12
by Squashman
liargof wrote:
15 May 2021 06:14
Thank you!

If I want to see each method running in separate CMD window, should I remove the "/b" that comes after the "start"?

What I want is that each method will run in loops in its own command window
What is stopping you from testing that code change?