Skip to content

Instantly share code, notes, and snippets.

@Frischifrisch
Forked from jnaskali/firewall_block.reg
Created June 20, 2021 22:35
Show Gist options
  • Save Frischifrisch/94b09f20eb3b308c1268b42e99b73d07 to your computer and use it in GitHub Desktop.
Save Frischifrisch/94b09f20eb3b308c1268b42e99b73d07 to your computer and use it in GitHub Desktop.
Block/Unblock exe in Windows Firewall using right-click menu (updated thanks to ghjbnm's comment below)
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\exefile\shell\WindowsFirewall]
@=""
"MUIVerb"="Windows Firewall"
"icon"="%SystemRoot%\\system32\\FirewallControlPanel.dll,0"
"subcommands"=""
[HKEY_CLASSES_ROOT\exefile\shell\WindowsFirewall\Shell]
@=""
[HKEY_CLASSES_ROOT\exefile\shell\WindowsFirewall\Shell\block]
@=""
"MUIVerb"="Block"
"icon"="%SystemRoot%\\system32\\FirewallControlPanel.dll,1"
[HKEY_CLASSES_ROOT\exefile\shell\WindowsFirewall\Shell\block\command]
@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -Executionpolicy ByPass -WindowStyle Hidden -NoLogo -Command \"start powershell -Verb runas -ArgumentList \\\"-NoLogo -WindowStyle Hidden -command `\\\"New-NetFirewallRule -DisplayName ([System.IO.Path]::GetFilenameWithoutExtension('%1')) -Name '%1' -Enabled True -Direction Outbound -Action Block -Program '%1'`\\\"\\\"\""
[HKEY_CLASSES_ROOT\exefile\shell\WindowsFirewall\Shell\Remove]
@=""
"MUIVerb"="Allow"
"icon"="%SystemRoot%\\system32\\FirewallControlPanel.dll,2"
[HKEY_CLASSES_ROOT\exefile\shell\WindowsFirewall\Shell\Remove\command]
@="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -Executionpolicy ByPass -WindowStyle Hidden -NoLogo -Command \"start powershell -Verb runas -ArgumentList \\\"-NoLogo -WindowStyle Hidden -command `\\\"Remove-NetFirewallRule -Name '%1'`\\\"\\\"\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment