Run program with different methods in loops

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
liargof
Posts: 2
Joined: 15 May 2021 01:35

Run program with different methods in loops

#1 Post by liargof » 15 May 2021 01:45

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

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Run program with different methods in loops

#2 Post by aGerman » 15 May 2021 04:59

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

liargof
Posts: 2
Joined: 15 May 2021 01:35

Re: Run program with different methods in loops

#3 Post by liargof » 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

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

Re: Run program with different methods in loops

#4 Post by Squashman » 15 May 2021 21:12

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?

Post Reply