static void Main(string[] args) { if (args.Length >= 1 && args[0] == "/fw") { Fw2Controller fw2 = new Fw2Controller(); fw2.AllowTCP(7777, NET_FW_PROFILE_TYPE2.ALL); return; } Settings.Default.SaveDir = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); IKernel kernel = new StandardKernel(new MainModule()); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(kernel.Get <Form1>()); }
public void Run() { Fw2Controller fw2 = new Fw2Controller(); var port = 7777; var allAllowed = fw2.EnumAllAllowed(); var alreadyAllowed = true && allAllowed.Contains($"domain,allow,tcp,{port}") && allAllowed.Contains($"private,allow,tcp,{port}") && allAllowed.Contains($"public,allow,tcp,{port}") ; if (!alreadyAllowed) { ProcessStartInfo psi = new ProcessStartInfo(GetType().Assembly.GetModules()[0].FullyQualifiedName, "/fw"); psi.Verb = "runas"; psi.UseShellExecute = true; Process.Start(psi); } }