【发布时间】:2026-01-27 15:00:01
【问题描述】:
我正在尝试从 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();
你知道它是什么吗?
非常感谢
【问题讨论】:
-
如果使用 /B 参数手动运行命令会发生什么。有用吗
-
刚尝试这样做,我看到了一些奇怪的东西。我发送的 context_param 不知何故搞砸了。其中一个斜线被转换为♀(一些奇怪的字符)
标签: java windows batch-file cmd