I have a batch file that runs ant and then copies one of the files that were produced:
ant -Dproject.version=1.1.2 release published copy /Y D:\dir1\MyJar.jar D:\dir2\MyJar.jar
When I run the batch file, ant runs successfully, but the copy statement never happens, although it will work just fine if I type it in and hit Enter after the ant task has finished.
What is going on here?
Pass the shell script (plus any arguments to the script) as a single command, using -c switch. cmd for batch files. Pass the batch files (plus any arguments to the script) as a single command, using /c switch.
Edit your bat file by right clicking on it and select “Edit” from the list. Your file will open in notepad. Now add “PAUSE” word at the end of your bat file. This will keep the Command Prompt window open until you do not press any key.
Can I control a program using a batch file once its been started? No. A batch file can only execute or start another program. Once it is started, it cannot perform additional functions within that program.
Short answer: yes, batch files can modify themselves whilst running.
I had the same problem once and the magic call
did it.
In that batch file of yours try:
call ant -Dproject.version=1.1.2 release published copy /Y D:\dir1\MyJar.jar D:\dir2\MyJar.jar
Cannot tell you why it worked, though. Guess it's Microsoft logic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With