Wednesday, September 24, 2014

Commandline to change firewal rules in Windows 7/8

I was looking for a commandline based approach to add new rules on Windows Firewall and it was simple to do:

  • First check if there are already some rules set:
    netsh advfirewall firewall show rule name=**App**
  • Then you add a separate rule for allowing input traffic (as required)
    netsh advfirewall firewall add rule name=**App** dir=in action=allow profile=public program=**App_Location** enable=yes
  • And a separate rule for allowing output traffic (as required)
    netsh advfirewall firewall add rule name=**App** dir=out action=allow profile=public program=**App_Location** enable=yes
  • Finally if required, the rule can be deleted
    netsh advfirewall firewall delete rule name=**App**

No comments: