我有一个看起来像这样的Windows BAT文件:
Z:
tool.exe c:mypathtoinput c:mypathtooutput flag1 flag2
也就是说,tool.exe位于映射的网络驱动器上。该工具要求EXE从其自己的目录(Z:在这种情况下)运行。
通过双击或在CMD窗口中运行时,蝙蝠正常工作。
我想通过蚂蚁自动化它。我的尝试是在这里:
<target name="go">
<exec executable="cmd">
<arg value="/c"/>
<arg value="runtool.bat"/>
</exec>
</target>
它不起作用。从此链接和其他研究中,我了解以下内容:
- " z:"可能等效于" cd z:"
- 没有Windows CMD Shell解释没有" CD.EXE" ..." CD",也无法通过" CMD.EXE" 使用
也就是说,如何实现蚂蚁的目标?在Java?
中我愿意编写自己的蚂蚁任务,对目录进行进一步的网络配置。p>
您必须在exec
任务上指定dir
属性:
<exec executable="tool.exe" dir="z:">
<arg value="c:mypathtoinput"/>
<arg value="c:mypathtooutput"/>
<arg value="flag1"/>
<arg value="flag2"/>
</exec>
这对我有用:
<target name="go">
<property name="batFileDir" location="${basedir}/resources" />
<exec executable="cmd" dir="." spawn="false">
<arg line="/C start ${batFileDir}/runTool.bat"/>
</exec>
</target>
runtool.bat如问题所述,并位于〜/resources中。