Dave's Brain

Browse - Programming Tips - How I can use Apache Ant to run a Windows batch file (script)?

Date: 2016aug19
Product: ant
Language: Java, xml
OS: Windows

Q.  How I can use Apache Ant to run a Windows batch file (script)?

A.  Use exec like this:

<exec dir="c:/path/to/my/batch" executable="cmd.exe"> <arg value="/c"/> <arg value="mybatch.bat"/> </exec>
Replace c:/path/to/my/batch with the actual path. Replace mybatch.bat with the actual name of your script. Main points: - you don't run the .bat directly - you need to specify /c to cmd.exe

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.