我正在尝试使用telnet使用Java来重新启动调制解调器应用程序。但是当必须输入用户名时,cmd停止。
private static void RebootModem() throws IOException {
String tel = "telnet 192.168.1.1 23";
String user = "admin";
String pass = "admin";
String reboot = "reboot";
String command = "cmd /c start cmd.exe /c" +tel+ "/c" +user+ "/c" +pass+"/c" +reboot;
try
{
Process child = Runtime.getRuntime().exec(command);
PrintWriter out = new PrintWriter(child.getOutputStream(), true);
}
catch(IOException e)
{
e.printStackTrace();
}
答案 0 :(得分:0)
然后执行此脚本
Set cloner = CreateObject("WScript.Shell")
cloner.run"cmd"
WScript.Sleep 500
cloner.run"telnet 192.168.2.1"
WScript.Sleep 500
cloner.SendKeys"username"
cloner.SendKeys("{Enter}")
WScript.Sleep 500
cloner.SendKeys"password"
cloner.SendKeys("{Enter}")
WScript.Sleep 500
cloner.SendKeys"reboot"
cloner.SendKeys("{Enter}")
WScript.Sleep 500
另存为.vbs 在java中 Runtime.getRuntime().exec(“ cmd / c start cmd.exe / K” + your_vbs_path);