Last active
October 7, 2021 11:40
-
-
Save sainf/4c09ae46f528d37eda97cd0a5381d161 to your computer and use it in GitHub Desktop.
Windows Firewall block all exe files in folder recursive
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
@echo off | |
@ setlocal enableextensions | |
@ cd /d "%~dp0" | |
echo. | |
echo This script file has to be copied to a folder that | |
echo contains the files you want to block on Windows Firewall. | |
echo It will block all .exe files in that folder and subfolders. | |
echo. | |
echo RUN IT AS ADMINISTRATOR | |
echo. | |
echo. | |
echo ------------------------------------------------- | |
echo Close the script now if it is not located | |
echo in the desired folder. | |
echo ------------------------------------------------- | |
echo. | |
PAUSE | |
cls | |
echo. | |
echo. | |
for /R %%a in (*.exe) do ( | |
echo ::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-:: | |
echo Blocking: %%a | |
echo - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
echo Outbound: | |
netsh advfirewall firewall add rule name="%%a" dir=out action=block program="%%a" | |
echo Inbound: | |
netsh advfirewall firewall add rule name="%%a" dir=in action=block program="%%a" | |
echo ::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-::-:: | |
echo. | |
) | |
echo. | |
echo :::::::::::::::: | |
echo Done | |
echo :::::::::::::::: | |
echo. | |
echo. | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment