Skip to content

Instantly share code, notes, and snippets.

@ph33nx
Last active July 10, 2024 10:33
Show Gist options
  • Save ph33nx/00084ffcf946427fb99fe25222ebc221 to your computer and use it in GitHub Desktop.
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
@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
)
@silentscope1
Copy link

what about unblocking all files script? i actually need to unblock programs now

@dopey123
Copy link

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