private void Run (){
Runtime rt = Runtime.getRuntime();
String filepath = "D:\\test.bat";
try {
rt.exec("cmd /c start" + "' '" + filepath);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}test.bat
echo ■test
call test.exe 5 4
为什么啊?
Runtime rt = Runtime.getRuntime();
String filepath = "D:\\test.bat";
try {
rt.exec("cmd /c start" + "' '" + filepath);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}test.bat
echo ■test
call test.exe 5 4
为什么啊?
解决方案 »
- ajax request.responseXML返回时报错
- java批处理与oracle过程的交互。。。。。。
- 广州的看看谢谢
- 求助在jsp里获得struts2 action里的变量并做判断.
- 关于JSP的tags标签
- 谁有struts2教程
- 用socket采用POST 方式请求一个servlet,但servlet能解析出参数名称来,参数不对,请问怎么回事啊
- Java操作ORACLE数据库Clob字段,我插入一个34k的文本的时候报错 java.sql.SQLException ora-21560:argument is null,invalid,or ou
- [在线求助]如下错误信息,请帮忙说一下解决办法,非常谢谢!
- highcharts
- dwr comet怎么做到给特定的用户发送消息!!
- 谁能 帮我在我的电脑上 一个 做 freemarker 案例
Runtime rt = Runtime.getRuntime();
String filepath = "D:\\test.bat"; // 会报错说找不到test.bat文件!!
// 如果不带路径的话,test.bat,就能调用成功,结果也能出来。
try {
rt.exec("cmd /c start " + filepath);//请问一下 start是什么参数啊?跟找文件的路径有关系吗
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}test.bat
echo ■test
call test.exe 5 4
你的test.bat是在D:的根目录下?
刚才String filepath = "D:\\test.bat";的时候是放在D盘根目录下
D:\eclipse4.2>echo test
test
D:\eclipse4.2>call text.exe 4 5
:4
:5
为啥它默认去找eclipse目录去了尼?
因为test.bat里要call test.exe,这两个文件都放D:\eclipse4.2的话,就能顺利执行
要是都放D:\,就说test.exe不是内部/外部命令咋办?
最上面加上cd d:
用ProcessBuilder也是一样,都是bat必须在eclipse下才能执行,是我哪里没配置好吗?怎么办呢?