How do I enable or disable Windows Firewall rules using the command prompt?

Solution 1:

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