Skip to content

Instantly share code, notes, and snippets.

@Snarp
Forked from jnaskali/firewall_block.reg
Created May 19, 2022 20:23
Show Gist options
  • Save Snarp/f93a5bc11ab0f4946442ef0da3ec7909 to your computer and use it in GitHub Desktop.
Save Snarp/f93a5bc11ab0f4946442ef0da3ec7909 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