你发布的代码使用自己的命令启动三个不同的过程。要打开命令提示符然后运行命令,请尝试以下操作(请勿自己尝试):
try { // Execute command String command = "cmd /c start cmd.exe"; Process child = Runtime.getRuntime().exec(command); // Get output stream to write from it OutputStream out = child.getOutputStream(); out.write("cd C:/ /r/n".getBytes()); out.flush(); out.write("dir /r/n".getBytes()); out.close();} catch (IOException e) {}


