Ant exec - 无法运行程序“start”创建进程错误=2

发布于 2024-08-15 18:21:02 字数 691 浏览 2 评论 0 原文

我无法使用 ant exec 运行 Windows“启动”。蚂蚁版本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”。

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

干杯 作为

I can't run the windows 'start' using ant exec. Ant version 1.7.1.

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

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?

cheers
a s

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岁吢 2024-08-22 18:21:02

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

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>

EDIT:

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>

but you mentioned that spawn="true" is not applicable for your environment, why is that?

我要还你自由 2024-08-22 18:21:02

我的解决方案

<project name="test"  basedir="." default="test-target">
<target name="start-init">
        <exec executable="where" outputproperty="START">
            <arg line="start" />
        </exec>
</target>
<target name="test-target">
        <exec executable="${START}">
            <arg line="cmd /c notepad" />  
        </exec>      
</target>
</project>

my solution

<project name="test"  basedir="." default="test-target">
<target name="start-init">
        <exec executable="where" outputproperty="START">
            <arg line="start" />
        </exec>
</target>
<target name="test-target">
        <exec executable="${START}">
            <arg line="cmd /c notepad" />  
        </exec>      
</target>
</project>
很酷不放纵 2024-08-22 18:21:02

怎么样?或者start.bat?

另外,basedir="." 指向哪里?如果您在 标记之前放置 ,它是否会打印正确的文件夹(里面有“启动”程序的那个)?

此外,您可以在 之前添加 以查看所有可见属性。

How about <exec executable="start.exe"> ? Or start.bat ?

Also, where is basedir="." pointing to? If you place a <echo message="basedir = ${basedir}"/> just before your <exec> tag, does it print the correct folder (the one with the "start" program in it)?

Additionally, you could add <echoproperties /> before <exec> to see all visible properties.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文