public void FirewallStart(bool flag) { if (IsFirewallInstalled) { if (flag) { manager.LocalPolicy.CurrentProfile.FirewallEnabled = true; } else { // there will be an exception if we try to turnoff windows firewall directly via API ConsoleSetups con = new ConsoleSetups(); con.RunExternalExe("netsh.exe", "Firewall set opmode disable"); } } }