Last active
November 23, 2025 15:26
-
-
Save skkut/11c68d47af09f2dca717bed5269eb517 to your computer and use it in GitHub Desktop.
A windows batch file to block all applications in a folder in Windows firewall
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ setlocal enableextensions | |
| @ cd /d "%~dp0" | |
| for /R %%a in (*.exe) do ( | |
| netsh advfirewall firewall add rule name="Blocked with Batchfile %%a" dir=out program="%%a" action=block | |
| ) |
This modification is 2x faster, as it doesn't wait for the incoming block to finish, also the reduced echo messages help a bit.
@echo off
cd /d "%~dp0"
set extensions=.exe .dll .com .bat .cmd .ps1 .vbs .js .py
for %%e in (%extensions%) do (
for /R %%a in (*%%e) do (
start /min "" netsh advfirewall firewall add rule name="Blocked %%~nxa (Incoming)" dir=in program="%%a" action=block
netsh advfirewall firewall add rule name="Blocked %%~nxa (Outgoing)" dir=out program="%%a" action=block >nul
echo Blocked: %%a
)
)
echo Done!
pause
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is what you need.