Waiting for end after calling BAT file

A

Alessandro

Is it possible to call a BAT file and make java code wait for script
execution end ??

Of course there could be many workaround like make bat script write a
particular file and java code makes polling or make java code wait for
a certain time, anyway I'd like to know if there is a direct way.

This is the bat file call:

//
Runtime runtime = Runtime.getRuntime();
runtime.exec("cmd /c start " + path + fileName);
//

Thanks and best rgds,
Alex
 
L

Lew

Alessandro multiposted:
Please do not multi-post. Cross-posted to bring replies together; f/u set to
comp.lang.java.help.
 
T

Thomas Kellerer

Steve W. Jackson, 03.03.2009 15:13:
That was my thought too, but a caveat might be in order...depending on
how faulty my memory is. I *think* I remember that the "start" command
will cause whatever is being launched to run separately. If so, then
the waitFor will return after the execution of the batch file without
waiting for whatever it launched.

If the OP wants to wait for the .bat execution he shouldn't use start ;)


runtime.exec("cmd /c " + path + fileName);

should work just fine (not tested)

Thomas
 
R

RedGrittyBrick

Alessandro said:
Is it possible to call a BAT file and make java code wait for script
execution end ??

Of course there could be many workaround like make bat script write a
particular file and java code makes polling or make java code wait for
a certain time, anyway I'd like to know if there is a direct way.

This is the bat file call:

//
Runtime runtime = Runtime.getRuntime();
runtime.exec("cmd /c start " + path + fileName);
//

Thanks and best rgds,
Alex

You multiposted - thanks for wasting my time!

Read this to find out what multiposting means
http://www.cs.tut.fi/~jkorpela/usenet/xpost.html
 
A

Arne Vajhøj

Steve said:
That was my thought too, but a caveat might be in order...depending on
how faulty my memory is. I *think* I remember that the "start" command
will cause whatever is being launched to run separately.

Me too.

Arne
 
A

Arne Vajhøj

Thomas said:
Steve W. Jackson, 03.03.2009 15:13:

If the OP wants to wait for the .bat execution he shouldn't use start ;)

runtime.exec("cmd /c " + path + fileName);

should work just fine (not tested)

Another potential issue is that if the command produces
lots of output, then iy may be necesarry to actually read
that.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top