windows - Ant exec - 无法运行程序 'start' CreateProcess 错误 = 2

标签 windows ant exec

我无法使用 ant exec 运行 Windows“开始”。 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

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

关于如何解决这个问题有什么建议吗?

干杯 一个 s

最佳答案

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"不适用于您的环境,这是为什么呢?

关于windows - Ant exec - 无法运行程序 'start' CreateProcess 错误 = 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1920882/

相关文章:

Windows 7驱动 Hook

windows - 如何手动创建可执行的 .exe PE 文件?

java - Ant、JUnit 和 TestSuite

python - 为什么 `exec()` 不在脚本中工作而是交互工作?

windows - 使用1394连接调试Windows XP内核

windows - 如何像在 Linux 中一样在 git bash 中通过向上/向下翻页启用历史搜索?

Java.net.连接异常 : Connection refused while building Ant

java - 使用 Ant 和 e(fx)clipse

java - 远程执行交互式 CLI 程序

Java Runtime.exec运行java问题