Windows – How to enable or disable Windows Firewall rules using the command prompt

windows 10windows firewall

I have some rules that I want to be toggled on and off. In Windows 10, how do I enable/disable these rules using the cmd prompt?

Best Answer

Run this in an elevated CMD (replace name with the name of your rule)

netsh advfirewall firewall set rule name="TestRule" new enable=yes

To disable the rule again run

netsh advfirewall firewall set rule name="TestRule" new enable=no
Related Question