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

我无法使用ant exec运行 windows‘start’. Ant版本1.7.1.

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

<project name="test"  basedir="." default="test-target">
<target name="test-target">
        <exec executable="start">
            <arg line="cmd /c notepad" />  
        </exec>      
</target>
</project>

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

Execute Failed: java.io.IOException: Cannot run program "start": Cre
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的内部命令,所以要启动你必须执行的操作:
<exec executable="cmd.exe">
        <arg line="/c start notepad" />  
    </exec>

编辑:

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

<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”不适用于你的环境,为什么呢?

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...