title: How to check if Firewall rule existed
body: <p>I have a button that's once clicked, it will add a new rule to firewall. BUT the problem is it can be clicked many times and will add many rules. </p>
  
  <p>How do I check if the rule exists in Firewall? (or is it possible to check rules?)</p>
  
  <p>Here's my code for adding a rule:</p>
  
  <pre><code>ProcessStartInfo run = new ProcessStartInfo();
  run.FileName = "cmd.exe";
  run.Verb = "runas";
  run.Arguments = "/C netsh advfirewall firewall add rule name=\"Block IP Rule\" dir=in interface=any action=block remoteip=x.x.x.x";
  run.WindowStyle = ProcessWindowStyle.Hidden;
  Process.Start(run);
  </code></pre>