windows – Ant exec – 无法运行程序’start’CreateProcess error = 2

前端之家收集整理的这篇文章主要介绍了windows – Ant exec – 无法运行程序’start’CreateProcess error = 2前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我无法使用ant exec运行 windows‘start’. Ant版本1.7.1.

以下是重新创建问题的示例build.xml

  1. <project name="test" basedir="." default="test-target">
  2. <target name="test-target">
  3. <exec executable="start">
  4. <arg line="cmd /c notepad" />
  5. </exec>
  6. </target>
  7. </project>

执行此生成文件时出现以下错误

  1. Execute Failed: java.io.IOException: Cannot run program "start": Cre
  2. ateProcess error=2,The system cannot find the file specified

我的env是Windows XP,Ant 1.7.1
我试图从DOS提示符运行它.
我排除任何与PATH相关的问题,因为我可以手动从DOS promt运行’start cmd / c notepad’.

对于如何解决这个问题,有任何的建议吗?

干杯
一个

start不是可执行文件,而是cmd.exe shell的内部命令,所以要启动你必须执行的操作:
  1. <exec executable="cmd.exe">
  2. <arg line="/c start notepad" />
  3. </exec>

编辑:

为了产生多个窗口,这应该工作:

  1. <target name="spawnwindows">
  2. <exec executable="cmd.exe" spawn="yes">
  3. <arg line="/c start cmd.exe /k echo test1" />
  4. </exec>
  5. <exec executable="cmd.exe" spawn="yes">
  6. <arg line="/c start cmd.exe /k echo test2" />
  7. </exec>
  8. </target>

但你提到spawn =“true”不适用于你的环境,为什么呢?

猜你在找的Windows相关文章