java 调用bat,dos窗口关闭问题 运行java程序,弹出dos窗口,显示任意键继续,点击回车,dos窗口没有关闭
java程序为:ProcessBuilderpb=newProcessBuilder(newString[]{"cmd","/C","start","d:/test.ba...
java程序为:
ProcessBuilder pb = new ProcessBuilder(new String[]
{ "cmd", "/C", "start", "d:/test.bat", "exit", "0" });
pb.directory(new File("D:\\"));
Process p = pb.start();
test.bat内容为:
pause 展开
ProcessBuilder pb = new ProcessBuilder(new String[]
{ "cmd", "/C", "start", "d:/test.bat", "exit", "0" });
pb.directory(new File("D:\\"));
Process p = pb.start();
test.bat内容为:
pause 展开
1个回答
2013-05-24
展开全部
不要用start参数,命令行的输出,通过 p.getInputStream() 来获取。还可以用 p.getOutputStream() 输出命令
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询