title: Ant target to run Windows BAT including changing directory
body: <p>I have a Windows BAT file that looks like this:</p>
  
  <pre><code>Z:
  tool.exe c:\mypath\to\input c:\mypath\to\output \flag1 flag2
  </code></pre>
  
  <p>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).</p>
  
  <p>The BAT works fine when run via double-click or in a CMD window.</p>
  
  <p>I'd like to automate it through Ant. My attempt is here:</p>
  
  <pre><code>&lt;target name="go"&gt;
      &lt;exec executable="cmd"&gt;
          &lt;arg value="/c"/&gt;
          &lt;arg value="runtool.bat"/&gt;
      &lt;/exec&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>It doesn't work. From <a href="http://www.velocityreviews.com/forums/t145516-ant-change-directory-command.html" rel="nofollow">this link</a> and other research, I understand the following:</p>
  
  <ul>
  <li>"Z:" is likely the equivalent of "cd Z:\"</li>
  <li>there is no "cd.exe"... "cd" is interpreted by the Windows CMD shell, and not available via "cmd.exe"</li>
  </ul>
  
  <p>That said, how to achieve the goal in Ant? in Java?</p>
  
  <p>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.)</p>