我正在尝试使用Process Builder运行批处理文件 批处理文件在另一个目录中
String filepath = "D:";
String filename = "hello.bat";
try {
ProcessBuilder p = new ProcessBuilder();
p.directory(new File(filepath));
p.command("cmd.exe", "/c ", filename);
Process process = p.start();
process.waitFor();
InputStream in = process.getInputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int c = -1;
while((c = in.read()) != -1)
{
baos.write(c);
}
String response = new String(baos.toByteArray());
System.out.println("Response From Exe : "+response);
没有引发异常,并且似乎卡在Process process = p.start();中。无限期地 此外,批处理文件本身不会执行 这里可能是什么问题? [我也尝试过Runtime#exec和Desktop#open,无济于事]
答案 0 :(得分:0)
概念将与此类似:Spring boot application.properties conflict when one application deploys another
我在那里提供了相当完整的代码集。