代码里面执行bat
public static void executeBat(String path) {
try {
File file = new File(path);
if (file.exists()) {
String parentpath = file.getParent();
parentpath = parentpath.replaceAll("\\\\", "/");
String fname = file.getName();
Runtime rntime = java.lang.Runtime.getRuntime();
if (Common.WINDOWS) {
if (!fname.endsWith(".bat")) {
fname = fname.substring(0, fname.lastIndexOf("."))
+ ".bat";
}
path = parentpath + "/" + fname;
Process process = rntime.exec("cmd /c start " + path);
}
}
} catch (Exception e) {
}
posted on 2013-11-29 11:00 lovebeauty 阅读(452) 评论(0) 编辑 收藏 举报