问题描述
我正在尝试从Java类执行一些批处理文件。 我希望批处理在不打开cmd窗口的情况下运行,我想等到完成为止。
当使用下面的命令(没有背景)时,它可以完美地工作:
String executeCmd = "cmd /c start /wait " +config.getJarPath()+ " --context_param Path=" +folderName;
final Process process = run.exec(executeCmd);
process.waitFor();
但是,当我添加/ b(在后台运行)时,批处理文件未运行:
String executeCmd = "cmd /c start /B /wait " +config.getJarPath()+ " --context_param Path=" +folderName;
final Process process = run.exec(executeCmd);
process.waitFor();
你有什么想法吗?
非常感谢
1楼
使用start /b
命令标签只需在当前窗口中启动程序。
B Start application without creating a new window.
如果要将批处理文件作为隐藏进程启动,则有一个简单的可以执行此操作。
或者,您可以使用并在转换时指定您希望exe成为Ghost应用程序
2楼
将/B
与/wait
一起使用时,它可以工作。
例如, cmd /c start /B /wait yourbatfile.bat