I have a Windows BAT file that looks like this:
Z:
tool.exe c:\mypath\to\input c:\mypath\to\output \flag1 flag2
That is, tool.exe resides on a mapped network drive. The tool requires that the EXE is run from its own directory (Z: in this case).
The BAT works fine when run via double-click or in a CMD window.
I’d like to automate it through Ant. My attempt is here:
<target name="go">
<exec executable="cmd">
<arg value="/c"/>
<arg value="runtool.bat"/>
</exec>
</target>
It doesn’t work. From this link and other research, I understand the following:
- “Z:” is likely the equivalent of “cd Z:\”
- there is no “cd.exe”… “cd” is interpreted by the Windows CMD shell, and not available via “cmd.exe”
That said, how to achieve the goal in Ant? in Java?
I’m open to writing my own Ant task, doing further network configuration of the directories, etc. (At the risk of making the question too broad, we are using Jenkins and open to ideas there as well.)
This worked for me:
where the runTool.bat is as described in the question, and located in ~/resources.