示例#1
0
        static void fwReset()
        {
            Type          netFwPolicy2Type = Type.GetTypeFromProgID("HNetCfg.FwPolicy2");
            INetFwPolicy2 mgr = (INetFwPolicy2)Activator.CreateInstance(netFwPolicy2Type);

            mgr.RestoreLocalFirewallDefaults();
        }
示例#2
0
        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();
        }
示例#3
0
        public void RestoreLocalFirewallDefaults()
        {
            INetFwPolicy2 firewallPolicy = GetFirewallPolicy();

            firewallPolicy.RestoreLocalFirewallDefaults();
        }