[英]Could not find or load Main class when trying to create batch file to run Java Program
[英]Batch file not executed when trying to run in background
我正在嘗試從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();
你有什么想法嗎?
非常感謝
使用start /b
命令標簽只需在當前窗口中啟動程序。
B Start application without creating a new window.
如果要將批處理文件作為隱藏進程啟動,則有一個簡單的vb腳本可以執行此操作。
或者,您可以使用Batch-To-Exe轉換器,並在轉換時指定您希望exe成為Ghost應用程序
將/B
與/wait
一起使用時,它可以工作。
例如, cmd /c start /B /wait yourbatfile.bat
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.