title: Execute Ant targets within environment set up by .cmd file
body: <p>I want to kick off an .exe from an Ant script. The .exe has a requirement that a .cmd file be run first to prep the environment. To be clear: if I open a console, run the .cmd first, and then my .exe, all is well. I'm working in Windows 7.</p>
  
  <p>This is what I currently have but it isn't working, I assume because the .cmd runs as its own process, and when control returns to Ant I've lost that scope so the next target runs and doesn't know anything about what happened in the .cmd file. Or at least that's what appears to be happening.</p>
  
  <p>I've messed around with different cmd switches, spawn true/false,  etc. but nothing really seems to be working and I am not sure what to Google for to see a working example of this situation.</p>
  
  <pre><code>&lt;target name="-someTarget"&gt;
    &lt;exec executable="cmd" spawn="false"&gt;
      &lt;arg value="/c" /&gt;
      &lt;arg value="somefile.cmd" /&gt;
    &lt;/exec&gt;
    &lt;exec executable="some.exe" spawn="false"&gt;
      &lt;arg value="-whatever" /&gt;
        &lt;arg value="somevalue" /&gt; &lt;!-- etc. --&gt;
    &lt;/exec&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>This is my workaround for now, but I would rather keep everything in my Ant script if possible.</p>
  
  <pre><code>&lt;target name="-someTarget"&gt;
    &lt;exec executable="cmd" spawn="false"&gt;
      &lt;arg line='/c somefile.bat "c:\some path\" an-arg "c:\another path\.txt" "c:\and another\.log"' /&gt;
    &lt;/exec&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>somefile.bat:</p>
  
  <pre><code>call %1\somefile.cmd
  call %1\some.exe %2 %3 %4
  </code></pre>