Skip to content

Instantly share code, notes, and snippets.

@ph33nx
Last active May 19, 2023 01:34
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
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment