Reputation: 7297
I have the following snippet in a batch file to run a program with an argument in a loop:
for /F "tokens=*" %%a in (some-list.txt) do (
java -jar some-java-package.jar com.example.package.class %%a
)
Sometimes the Java application crashes on a memory exception (this could be an important point, because according to my current programming experience these seem to be special exceptions and I was not able to catch them like I would catch normal exceptions in program code).
In such a case it seems my batch script pauses until I take action: I can press Ctrl-C
and on batch's question if I want to stop the batch job respond N
, then it will continue with the next program call.
Is it possible to tell batch to go on in such events automatically?
Upvotes: 0
Views: 206
Reputation: 34899
You should call java
using the start
command like this:
for /F "tokens=*" %%a in (some-list.txt) do (
start "" /WAIT "java" -jar some-java-package.jar com.example.package.class %%a
)
The /WAIT
switch lets start
wait until the application (java
) has finished execution.
The ""
portion defines the window title (this is defined here since start
sometimes confuses it with the command line when no title given).
Upvotes: 2