使用java程序运行批处理文件 [英] Run a batch file with java program
本文介绍了使用java程序运行批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
try {
try {
String[] command = {"cmd.exe", "/C", "Start", "D:\\test.bat"};
Runtime r = Runtime.getRuntime();
Process p = r.exec(command);
p.waitFor();
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(this, "Error" +"Execution!","Error",JOptionPane.ERROR_MESSAGE);
}
} catch (IOException ex) {
Logger.getLogger(DBBackUp.class.getName()).log(Level.SEVERE, null, ex);
}
当我运行此代码时,我只得到命令promt。 .bat文件未运行。
如何使用此代码执行批处理文件?
When I run this code, I got only command promt. .bat file is not running. How can I execute the batch file using this code?
提前感谢
推荐答案
这篇关于使用java程序运行批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文