你好请问java如何调用bat文件,并传递参数啊……我的qq474659049 谢谢你了

 我来答
匿名用户
2012-06-27
展开全部
找了个例子:
bat文件:
@echo off
cd c:\
echo set sh=WScript.CreateObject("WScript.Shell") >telnet_tmp.vbs
echo WScript.Sleep 300 >>telnet_tmp.vbs
echo sh.SendKeys "open %1{ENTER}">>telnet_tmp.vbs
echo WScript.Sleep 3000 >>telnet_tmp.vbs
echo sh.SendKeys "%2{ENTER}" >>telnet_tmp.vbs
echo WScript.Sleep 3000 >>telnet_tmp.vbs
echo sh.SendKeys "%3{ENTER}">>telnet_tmp.vbs
echo WScript.Sleep 3000 >>telnet_tmp.vbs
echo sh.SendKeys "reboot{ENTER}">>telnet_tmp.vbs
echo WScript.Sleep 3000 >>telnet_tmp.vbs
echo sh.SendKeys "exit{ENTER}">>telnet_tmp.vbs
echo WScript.Sleep 5000 >>telnet_tmp.vbs
echo sh.SendKeys "{ENTER}">>telnet_tmp.vbs
echo WScript.Sleep 3000 >>telnet_tmp.vbs
echo sh.SendKeys "q{ENTER}">>telnet_tmp.vbs
start telnet

cscript //nologo telnet_tmp.vbs
del telnet_tmp.vbs

action:
String path=ServletActionContext.getServletContext().getRealPath("//WEB-INF//classes//reboot.bat");
String command=path+" "+this.getIp()+" "+this.remotName+" "+this.remotPassword;
try {
Process ps = Runtime.getRuntime().exec(command);
} catch (IOException e) {
e.printStackTrace();
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式