Use properties as input, something like :
<project>
<property name="foobar" location="C:/foobar" />
<property name="foo" value="bar" />
<exec executable="cmd">
<arg value="/c" />
<env key="PATH" path="${env.PATH};${foobar}/bin" />
<arg value="set" />
</exec>
<exec executable="cmd">
<arg value="/c" />
<arg value="echo" />
<arg value="${foo}" />
</exec>
</project>
You have to use /c as first arg value.
When calling a batfile which expects %1 ... %9 as input, first arg is <arg value=/c">,
second arg <arg value="yourbatfile.bat/>.
The following args <arg value=.../> would be %1 and so on, f.e. :
foobar.bat
@echo off
echo First argument %1
echo Second argument %2
build.xml
<project>
<exec dir="dir="path/to/batfile" executable="cmd">
<arg value="/c"/>
<arg value="foobar.bat"/>
<arg value="foo"/>
<arg value="bar"/>
</exec>
</project>
output
[exec] First argument foo
[exec] Second argument bar
Example for calling a shellscript, first arg has to be <arg value="/path/to/shellscript.sh"/>, the following args <arg value="..."/> will be $1 ...
foobar.sh
#!/bin/bash
echo "\$# = $#"
echo "\$0 = $0"
echo "\$1 = $1"
echo "\$2 = $2"
build.xml
<project>
<exec executable="/bin/bash">
<arg value="/path/to/foobar.sh"/>
<arg value="foo"/>
<arg value="bar"/>
</exec>
</project>
%1,%2and so on - I assume you use Windows batch scripts.$1,$2and so on.