Skip to content

Instantly share code, notes, and snippets.

@otsmr
Created June 6, 2019 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save otsmr/d8c03ce64e9d6753f74766007ba736f6 to your computer and use it in GitHub Desktop.
Save otsmr/d8c03ce64e9d6753f74766007ba736f6 to your computer and use it in GitHub Desktop.
@echo off
@setlocal enableextensions
@setlocal EnableDelayedExpansion
@cd /d "%~dp0"
color 06
title Firewall
set location=%cd%
echo.
echo. ========================================================
echo. Firewall 1.0
echo. ========================================================
echo.
call:checkPerm
echo.
echo. .exe Dateien werden in %location% gesucht.
echo.
echo. Treffer:
echo. ------------------------------------------
FOR /r %%B in (*.exe) do (echo. %%~nxB)
echo. ------------------------------------------
echo.
CHOICE /C jn /M "> Firewall Regeln hinzufuegen"
IF Errorlevel 2 goto EXIT
IF Errorlevel 1 goto ADD
:ADD
echo.
set /p add="> Name der Regel: "
:block
set c=0
echo.
echo. Eingehende Regeln:
echo. ------------------------------------------
FOR /r %%B in (*.exe) do (
set /a c=!c!+1
echo. !c!. '%%~nxB' wird blockiert...
netsh advfirewall firewall add rule name="%add% (%%~nxB)" dir=in action=block program="%%~dpfnxB"
)
echo. ------------------------------------------
echo.
echo. Ausgehende Regeln:
echo. ------------------------------------------
set c=0
FOR /r %%B in (*.exe) do (
set /a c=!c!+1
echo. !c!. '%%~nxB' wird blockiert...
netsh advfirewall firewall add rule name="%add% (%%~nxB)" dir=out action=block program="%%~dpfnxB"
)
echo. ------------------------------------------
echo.
CHOICE /C jn /M "> Windows Firewall oeffnen?
IF Errorlevel 2 goto EXIT
IF Errorlevel 1 goto OPEN
:OPEN
start "C:\Windows\System32" rundll32.exe shell32.dll,Control_RunDLL firewall.cpl
Goto EXIT
:checkPerm
net session >nul 2>&1
if %errorLevel% == 0 (
echo. Permissions: OK
) else (
color 04
echo. Permissions: FALSE
echo.
echo. Das Programm benoetigt Administratorrechten.
pause>nul
goto exit
)
cd %~dp0
goto:eof
:EXIT
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment