Skip to content

Instantly share code, notes, and snippets.

@jnaskali
Last active December 9, 2025 13:00
Show Gist options
  • Select an option

  • Save jnaskali/5936789 to your computer and use it in GitHub Desktop.

Select an option

Save jnaskali/5936789 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'`\\\"\\\"\""
Copy link

ghost commented Jun 20, 2020

Following worked for me (Windows 10 Build 1909)

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'`\\\"\\\"\""

@jnaskali
Copy link
Author

Following worked for me (Windows 10 Build 1909)

I updated the gist using your solution. Thanks!

@jpeni
Copy link

jpeni commented Jun 25, 2020

jnaskali
Any chance of including the update DATE in the gist when you change it?

@Owned67
Copy link

Owned67 commented Jan 6, 2024

22h2 it does not work for me...

@tommcg
Copy link

tommcg commented Jan 10, 2024

22h2 it does not work for me...

Same. Not working. I have no clue how to fix it. I tried to tweak it, but no success.

@Owned67
Copy link

Owned67 commented Jan 13, 2024

22h2 it does not work for me...

Same. Not working. I have no clue how to fix it. I tried to tweak it, but no success.

ive found easy context menu, it make this and work

@HellPhantom
Copy link

I would suggest also trying "OneClickFirewall" from Winearo for the more technology challenged ones. Even has nice colorful buttons :-)

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