Ant exec - cannot run program 'start' CreateProcess error=2

后端 未结 3 1575
孤街浪徒
孤街浪徒 2020-12-20 16:22

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

Here is sample build.xml to recreate the problem



        
相关标签:
3条回答
  • 2020-12-20 16:45

    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>
    
    0 讨论(0)
  • 2020-12-20 16:46

    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?

    0 讨论(0)
  • 2020-12-20 17:02

    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.

    0 讨论(0)
提交回复
热议问题