tags:

views:

65

answers:

3

I have two "exe"(A and B) files and a input(C) file.

  • Firstly, The A file will take C as input to execute and then update input(C) file.
  • Next, B file will take C as input to execute and then update input(C) file.
  • ...
  • ...
  • ...

These two steps will repeat multiple times.

Which kind of command should I use?

A: 

Sounds scary...

You need to keep File Locking in mind so your applications do not step all over each other.

Two processes that modify the same shared resource can lead to all sorts of troubles.

Is this for work/fun or school?

Robert Greiner
Yes, just for doing TA job.
FihopZz
A: 

@Echo Off
SETLOCAL EnableDelayedExpansion
SET LIST=cmd cmd

FOR %%G IN (%LIST%) DO (
SET NAME=%%G
START /WAIT CMD /C !NAME!
)

Hypnos
How to control the times of loop if using start?
FihopZz
I was merely responding to Roberts valid point regarding file locking. When you wrap the execution to the loop, the loop will wait until the first program exits before launching another iteration. See simple edited test.
Hypnos
Thanks you very much. I have figured out my problem using Matlab. Matlab are allowed to embed dos command. So in this way, I can use the "for" loop in Matlab. At last, Thanks again.
FihopZz
A: 

You can use for loops in batch files. It's not completely clear what you are wanting, but the following command will run a.exe and then b.exe 3 times each passing the parameter c.dat to each one:

for /l %l in (1,1,3) do for %a in (a.exe b.exe) do %a c.dat
Mark Wilkins
This is really helpful. I have another question. If I have to execute a "exe" file and a java file(.class). How should I write it. I have tried it in this way: "for /l %l in (1,1,3) do a.exe c.dat java b c.dat".But it failed.
FihopZz
@FihopZz, In that situation, it might be simpler to make another batch file (b.bat maybe) that runs the java app.
Mark Wilkins
Thanks you very much. I have figured out my problem using Matlab. Matlab are allowed to embed dos command. So in this way, I can use the "for" loop in Matlab. At last, Thanks again.
FihopZz
@FihopZz: Cool - thanks for letting us know you got it working. If one of the answers that people provided works, you should select the checkmark icon on whichever one helped. If equally helpful, select one at random :)
Mark Wilkins