Score:0

CMD - Check if exist firewall rule, and add if not

in flag

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!!!

kapi avatar
in flag
the problem is that it has to run in win7 too, some version not have PS :(
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.