Skip to content

Instantly share code, notes, and snippets.

@ethanpil
Last active April 14, 2022 18:54
Show Gist options
  • Save ethanpil/ade06a8e27c8f190b070eb8788b7afd8 to your computer and use it in GitHub Desktop.
Save ethanpil/ade06a8e27c8f190b070eb8788b7afd8 to your computer and use it in GitHub Desktop.
Create Windows Firewall Rules via CMD

General Syntax

netsh advfirewall firewall add rule name="RULENAME" dir=[in/out] action=[allow/block/bypass] protocol=[tcp/udp] localip=[any] remoteip=[any]

Block a program (executable)

netsh advfirewall firewall add rule name="Block My EXE" dir=out program="c:\Program Files\Folder\blockme.exe" profile=any action=block

Open a port

netsh advfirewall firewall add rule name="allowPort80" dir=in action=allow protocol=TCP localport=80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment