我正在使用 Sikuli 来执行我的自动化测试,并且我正在编写一个小型 java 应用程序来运行我的测试。我已经搜索了其他答案,但大多数都与从 java 运行批处理脚本有关,我需要从 java 运行整个命令。我有以下命令从 cmd 运行 Sikuli:
Process p = Runtime.getRuntime().exec("cmd /c start /wait C:\\Sikuli\\runIde.cmd -r C:\\Sikuli\\xmlRunner\\runners\\Runner.sikuli --args 5");
System.out.println("Waiting for command to be executed");
p.waitFor();
System.out.println("Command finished");
这将启动一个新的 cmd 窗口并开始执行我的脚本,但当脚本完成时,它不会关闭 cmd 窗口。有没有办法在我的脚本运行完毕后自动关闭cmd窗口?
最佳答案
使用cmd /c start /wait cmd /c C:\\Sikuli\\runIde.cmd -r C:\\Sikuli\\xmlRunner\\runners\\Runner.sikuli --args 5
查看 jetty :
WAIT Start application and wait for it to terminate.
command/program
If it is an internal cmd command or a batch file then
the command processor is run with the /K switch to cmd.exe.
This means that the window will remain after the command
has been run.
If it is not an internal cmd command or batch file then
it is a program and will run as either a windowed application
or a console application.
当您直接调用runIde.cmd
时/K
应用开关,但是当您使用 cmd.exe
代理此调用时此规则不适用。
关于java - 命令执行时关闭 CMD 窗口 - Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46318407/