static void fwReset() { Type netFwPolicy2Type = Type.GetTypeFromProgID("HNetCfg.FwPolicy2"); INetFwPolicy2 mgr = (INetFwPolicy2)Activator.CreateInstance(netFwPolicy2Type); mgr.RestoreLocalFirewallDefaults(); }
static void resetFirewall() { /* * try * { * var p = new Process(); * var pInfo = new ProcessStartInfo() * { * FileName = "netsh.exe", * Arguments = "advfirewall reset", * CreateNoWindow = true, * UseShellExecute = false, * RedirectStandardError = false, * RedirectStandardInput = false, * RedirectStandardOutput = false, * }; * * p.StartInfo = pInfo; * p.Start(); * } * catch (Exception ex) * { * Console.WriteLine(ex.Message); * errText(2); * } */ Type netFwPolicy2Type = Type.GetTypeFromProgID("HNetCfg.FwPolicy2"); INetFwPolicy2 mgr = (INetFwPolicy2)Activator.CreateInstance(netFwPolicy2Type); mgr.RestoreLocalFirewallDefaults(); }
public void RestoreLocalFirewallDefaults() { INetFwPolicy2 firewallPolicy = GetFirewallPolicy(); firewallPolicy.RestoreLocalFirewallDefaults(); }