java实现dos命令
zings 2009-12-01 09:41:40 我想用Java实现dos下执行多条命令,想如下这样:
String cmd5 = "net use o: \\10.8.0.90\netfile 123.com/user:administrator";
String cmd6 = "copy o:\\test.txt E:\\share\\cpu.txt"; //cpuinfo.txt
String cmd7 = "net use o: /del";
String cmd8 = "exit";
Runtime.getRuntime().exec("cmd /c start");
// Process process =
Runtime.getRuntime().exec("dir ");
// process.waitFor();
// Process process1 =
Runtime.getRuntime().exec("ipconfig" );
// process1.waitFor();
// Process process2 = Runtime.getRuntime().exec(cmd6);
//// process2.waitFor();
// Process process3 = Runtime.getRuntime().exec(cmd7);
//// process3.waitFor();
// Process process4 = Runtime.getRuntime().exec(cmd8);
// process4.waitFor();
Process process5 = Runtime.getRuntime().exec("exit");
process5.waitFor();
// Process process2 = Runtime.getRuntime().exec("cmd /c dir");
// process2.waitFor();
但是不能得到自己想要的结果。。。执行一条还行,但是执行多条就有问题,请高手指点!!!
如何用Java实现本地dos命令下的多条指令!!!想copy , dir 。。。等
谢谢!!!