File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes .bat Executed Direct from exec Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark ".bat Executed Direct from exec" Watch ".bat Executed Direct from exec" New topic

.bat Executed Direct from exec

Chris Bohannon

Joined: Jul 28, 2009
Posts: 8


I have an Ant related question. According to the Ant manual:

Note that .bat files cannot in general by executed directly. One normally needs to execute the command shell executable cmd using the /c switch.

Here is a code snippet:

This seems to work just fine. I am executing a .bat file directly from the exec task. Now the manual states "general" usage, but I am wondering if I should use the recommend method or is it safe to do what I am doing?

Peter Johnson

Joined: May 14, 2008
Posts: 5852

That might be really old text because if I recall correctly that was a problem many years ago. If it is working for you, go for it.

JBoss In Action
I agree. Here's the link:
subject: .bat Executed Direct from exec
It's not a secret anymore!