Garfield
Garfield

Reputation: 185

How to make batch file continue running when the triggered exe crashes

I have a batch script that triggers an exe (c++ code) with command line input in a loop.

The code for this is something like this:

for /f %%j in (file.txt) do (
"MyExe.exe" "input\MyInput_%%j.txt"
)

"file.txt" contains list of input file names. The problem is, sometimes my exe crashes for some input files. When it crashes, script stops running and it requires manual intervention.

How can this be corrected so that when ever exe crashes, my script could just display a message and continues executing with next input?

I am running the script on windows XP but a OS free solution would be better.

Upvotes: 0

Views: 3229

Answers (1)

John P
John P

Reputation: 15245

Try running it within another instance. Something like this:

for /f %%j in (file.txt) do (
    cmd.exe /C "MyExe.exe" "input\MyInput_%%j.txt"
)

Upvotes: 2

Related Questions