Last active
April 1, 2025 19:52
-
-
Save ph33nx/00084ffcf946427fb99fe25222ebc221 to your computer and use it in GitHub Desktop.
Windows Firewall - Block All .Exe's Inside a folder from accessing Internet using batch script | Block all .exe in a folder to access Internet
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
@REM This batch script loops through all exe's inside a directory and blocks all .exe's inside that folder and its subfolders using windows inbuilt firewall. | |
@REM IMP: Replace FOLDER_NAME with the folder in which you want all .exe's blocked. or replace the whole url, for ex: C:\Program Files\Adobe | |
@ setlocal enableextensions | |
@ cd /d "%~dp0" | |
@for /R "C:\Program Files\FOLDER_NAME" %%a in (*.exe) do ( | |
netsh advfirewall firewall add rule name="%%~na (Blocked using script)" dir=out program="%%a" action=block | |
netsh advfirewall firewall add rule name="%%~na (Blocked using script)" dir=in program="%%a" action=block | |
) |
At the end of line 10 and 11 where it says ‘block’ replace with ‘allow’.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what about unblocking all files script? i actually need to unblock programs now