我无法使用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>
Run Code Online (Sandbox Code Playgroud)
执行此生成文件时出现以下错误:
Execute failed: java.io.IOException: Cannot run program "start": Cre
ateProcess error=2, The system cannot find the file specified
Run Code Online (Sandbox Code Playgroud)
我的env是Windows XP,Ant 1.7.1我试图从DOS提示符运行它.我排除任何与PATH相关的问题,因为我可以手动从DOS promt运行'start cmd/c notepad'.
对于如何解决这个问题,有任何的建议吗?
欢呼声
ben*_*y23 14
start不是可执行文件,而是cmd.exe shell的内部命令,因此要启动您必须执行的操作:
<exec executable="cmd.exe">
<arg line="/c start notepad" />
</exec>
Run Code Online (Sandbox Code Playgroud)
编辑:
为了产生多个窗口,这应该工作:
<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>
Run Code Online (Sandbox Code Playgroud)
但你提到spawn ="true"不适用于你的环境,为什么呢?
小智 0
怎么样<exec executable="start.exe">
?或者start.bat?
另外,basedir="."
指向哪里?<echo message="basedir = ${basedir}"/>
如果您在标签之前放置<exec>
,它是否会打印正确的文件夹(其中包含“启动”程序的文件夹)?
此外,您可以添加<echoproperties />
之前<exec>
以查看所有可见属性。
归档时间: |
|
查看次数: |
24537 次 |
最近记录: |