输入路由器IP,用户名和密码,执行此函数即可重启路由器,仅支持TP-LINK、水星、FAST这三个品牌路由器(其实它们是一家,不懂→百度)
public static bool rebootRouter(string ip, string user, string passwd) { try { byte[] bytes = Encoding.Default.GetBytes(user + ":" + passwd); string base64str = Convert.ToBase64String(bytes); string url = "http://" + ip + "/userRpm/SysRebootRpm.htm?Reboot=%D6%D8%C6%F4%C2%B7%D3%C9%C6%F7"; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Referer = "http://" + ip + "/userRpm/SysRebootRpm.htm"; req.Headers.Add(HttpRequestHeader.Authorization, "Basic " + base64str); req.Method = "GET"; req.GetResponse(); return true; } catch (Exception e) { Console.Write(e.Message); } return false; } |
转载请注明:http://www.shenyaocn.com/?p=123