Created
May 8, 2021 08:29
-
-
Save Mosdatlan-falusi/c6573d40c0ffe415ac908ac0aa17b155 to your computer and use it in GitHub Desktop.
Creates a firewall rule for all .exe files in it s folder and in all folders below.
This file contains 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 ADMINISTATOR | |
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