I need some help to make an script that check if exist a rule, and add if not. It auto add all exe inside a folder where i run it.
@echo off
cls
Echo.--------------------------------------------------------------------------------------------------------------
FOR /r %%G in ("*.exe") Do (
netsh advfirewall firewall show rule name=all | find "Nombre de regla:" | find "%%G" > nul
if %errorlevel% EQU 1 (
@echo Added - %%G
NETSH advfirewall firewall add rule name="%%G" dir=in program="%%G" action="block" enable="yes" > nul
NETSH advfirewall firewall add rule name="%%G" dir=out program="%%G" action="block" enable="yes" > nul
) else (
@echo Exist- %%G
)
)
Echo.--------------------------------------------------------------------------------------------------------------
Echo.
Echo End.
Echo.
pause
What I doing wrong? Thank you!!!