[英]exit bat file after an execution in cmd
Im running a selenium TestNG script using ANT in eclipse. 我在日食中使用ANT运行硒TestNG脚本。 The execution completes but the cmd prompt stays there even after the execution when i try to run the bat file from java.
执行完成,但是当我尝试从Java运行bat文件时,即使执行后cmd提示符仍停留在该位置。 But when i run the bat file by double clicking it, the cmd exit after execution.
但是当我通过双击运行bat文件时,执行后cmd退出。 Here below are the code to invoke the bat file and content of bat file:
以下是调用bat文件和bat文件内容的代码:
Runtime.getRuntime()
.exec("cmd /c start run.bat", null, new File("C:\\Users\\nvithushan\\Desktop\\HSBC\\gen\\seleniumwebdriver\\HSBC_Demo"));
This is the content of the batch file. 这是批处理文件的内容。
@echo off
echo exectution starting
start ant
exit
Any help 任何帮助
It should be sufficient in your exec to do cmd /c run.bat
and in your batch file just do ant.bat
or call ant.bat
. 在您的exec中执行
cmd /c run.bat
应该足够了,而在批处理文件中只需执行ant.bat
或call ant.bat
。 By definition the start command starts a separate cmd process. 根据定义,启动命令将启动一个单独的cmd进程。 Note also the documentation:
另请注意文档:
If [the command you run] is an internal cmd command or a batch file then the command processor is run with the /K switch to cmd.exe.
如果[您运行的命令]是内部cmd命令或批处理文件,则使用/ K切换到cmd.exe来运行命令处理器。 This means that the window will remain after the command has been run.
这意味着该窗口将在运行命令后保留。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.