Ant exec - 无法运行程序 'start' CreateProcess 错误=2 [英] Ant exec - cannot run program 'start' CreateProcess error=2
问题描述
我无法使用 ant exec 运行 windows 'start'.蚂蚁版本1.7.1.
I can't run the windows 'start' using ant exec. Ant version 1.7.1.
这是重新创建问题的示例 build.xml
Here is sample build.xml to recreate the problem
<project name="test" basedir="." default="test-target">
<target name="test-target">
<exec executable="start">
<arg line="cmd /c notepad" />
</exec>
</target>
</project>
执行此构建文件时出现以下错误:
getting the following error when I execute this build file:
Execute failed: java.io.IOException: Cannot run program "start": Cre
ateProcess error=2, The system cannot find the file specified
我的环境是 Windows XP,Ant 1.7.1我正在尝试从 DOS 提示符运行它.我排除了任何与 PATH 相关的问题,因为我可以从 DOS 提示符手动运行start cmd/c notepad".
My env is Windows XP, Ant 1.7.1 I am trying to run this from DOS prompt. I rule out any PATH related issues, as I could run 'start cmd /c notepad' from DOS promt manually.
有关如何解决此问题的任何建议?
Any suggestions on how to fix this?
干杯一个
推荐答案
start 不是可执行文件,而是 cmd.exe shell 的内部命令,因此要启动某些内容,您必须:
start is not an executable but is an internal command of the cmd.exe shell, so to start something you'd have to:
<exec executable="cmd.exe">
<arg line="/c start notepad" />
</exec>
对于生成多个窗口,这应该有效:
For spawning multiple windows, this should work:
<target name="spawnwindows">
<exec executable="cmd.exe" spawn="yes">
<arg line="/c start cmd.exe /k echo test1" />
</exec>
<exec executable="cmd.exe" spawn="yes">
<arg line="/c start cmd.exe /k echo test2" />
</exec>
</target>
但是您提到 spawn="true" 不适用于您的环境,这是为什么呢?
but you mentioned that spawn="true" is not applicable for your environment, why is that?
这篇关于Ant exec - 无法运行程序 'start' CreateProcess 错误=2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!