static void Main(string[] args) { if (args.Length > 0) { if (args[0] == "create") { CreateConnection createConn = new CreateConnection(); createConn.CreateVPN(args[1], args[2]); } else if (args[0] == "connect") { CreateConnection createConn = new CreateConnection(); createConn.ConnectVPN(args[1], args[2], args[3]); } else if (args[0] == "fixReg") { CreateConnection createConn = new CreateConnection(); createConn.FixReg(); } else { Console.WriteLine("WRONG COMMAND!"); Console.WriteLine("create <name> <destination> create a new vpn"); Console.WriteLine("connect <name> <username> <pwd> connect to a vpn"); Console.WriteLine("fixReg fix registry"); } } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new VPNCreateForm()); } }
private void btn_ConnectVpn_Click(object sender, EventArgs e) { try { CreateConnection createConn = new CreateConnection(); createConn.ConnectVPN(txt_VpnName.Text, txt_UserName.Text, txt_Pwd.Text); MessageBox.Show("Connect to VPN Success!"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }