import java.io.IOException;
public class ExecuteDosCommand {
public static void main(String[] args) throws IOException, InterruptedException {
String cmd = null;
try {
String s = "command.exe";
Runtime.getRuntime().exec(s);
cmd = s;
} catch (Exception ex) {
// ex.printStackTrace();
}
try {
String s = "cmd.exe";
Runtime.getRuntime().exec(s);
cmd = s;
} catch (Exception ex) {
// ex.printStackTrace();
}
String s = String.format("%s /C start %s", cmd, "c:\\新增文字文件.txt");
System.err.println(s);
Runtime.getRuntime().exec(s);
}
}
When Runtime.exec() won't