static int Main(string[] args) { try { string usage = "RouterRebootCmd password [ip]"; string ip = "192.168.0.1"; string password = ""; if (args.Length > 2 || args.Length < 1) { Console.WriteLine(usage); throw new ArgumentException("Invalid command line arguments"); } password = args[0]; if (args.Length == 2) ip = args[1]; DLinkScript.Application app = new DLinkScript.Application(ip); Console.WriteLine("Logging in..."); app.Login(password); Console.WriteLine("Logged in"); app.Reboot(); Console.WriteLine("Rebooting..."); return 0; } catch (Exception ex) { Console.WriteLine(ex.Message); return 1; } }
static int Main(string[] args) { try { string usage = "RouterRebootCmd password [ip]"; string ip = "192.168.0.1"; string password = ""; if (args.Length > 2 || args.Length < 1) { Console.WriteLine(usage); throw new ArgumentException("Invalid command line arguments"); } password = args[0]; if (args.Length == 2) { ip = args[1]; } DLinkScript.Application app = new DLinkScript.Application(ip); Console.WriteLine("Logging in..."); app.Login(password); Console.WriteLine("Logged in"); app.Reboot(); Console.WriteLine("Rebooting..."); return(0); } catch (Exception ex) { Console.WriteLine(ex.Message); return(1); } }
private void btnReboot_Click(object sender, RoutedEventArgs e) { try { DLinkScript.Application app = new DLinkScript.Application(tbIp.Text); app.Login(pbPassword.Password); app.Reboot(); MessageBox.Show("Rebooting now"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }