New
#11
Last edited by Brink; 11 Jan 2018 at 17:38. Reason: fixed quote box
It would help a lot of people if someone could add to that code so that the user specifies a folder and the batch file creates blocking inbound/outbound rules for every .exe and .dll including every subfolder. I just don’t know how… I only speak Java and C++
...I don't know anything about the syntax for these batch files
Actually some one already did that:
https://sites.google.com/site/mytool...ws-7-firewall/
How could I add this script below another script (together) in a .bat and that would run portable (from other places) for example: from E:\ and look for all the .exe of a folder in another location for example: "%ProgramFiles% Myprogram" ?Thanks in advance!
Thanks for the comment spapakons. I was wondering if there is any way to add this escript to block all .exe from the program folder. for example, after installing it silently. Without having to manually move to the installed folder understand. All in one single batMay .batfile:@setlocal enableextensions@cd /d "%~dp0"start /wait "may program.exe" /spara %% G in ("C:\Program Files (x86)\My program\*.exe") do (netsh advfirewall firewall adicionar nome da regra = "Bloqueado com Batchfile %% G" dir = em ação = bloco programa = "%% G" habilitar = sim perfil = qualquernetsh advfirewall firewall adicionar nome da regra = "Bloqueado com Batchfile %% G" dir = out action = block program = "%% G" enable = yes profile = any)exit
Thank youworks well !!Sorry for the other comments from me.Just one more question, how could I do to run the folder and subfolders ...?Thanks in advance
I'm really puzzled and looking for help.
I have used .bat from post#10 How to block multiple EXE files Windows Firewall on Win 10 LTSC v.1809 b.17763.4974. Before using it restored firewall defaults.
Code:FOR /r %%G in ("*.exe") Do (@echo %%G NETSH advfirewall firewall add rule name="%RULENAME%-%%~nxG" dir=in program="%%G" action="block" enable="yes") FOR /r %%G in ("*.exe") Do (@echo %%G NETSH advfirewall firewall add rule name="%RULENAME%-%%~nxG" dir=out program="%%G" action="block" enable="yes") FOR /r %%G in ("*.dll") Do (@echo %%G NETSH advfirewall firewall add rule name="%RULENAME%-%%~nxG" dir=in program="%%G" action="block" enable="yes") FOR /r %%G in ("*.dll") Do (@echo %%G NETSH advfirewall firewall add rule name="%RULENAME%-%%~nxG" dir=out program="%%G" action="block" enable="yes")
It added blocking rules for all .exe & .dll in the folder as intended, but at the same time all files are showed in 'Allow apps to communicate through Windows Defender Firewall'. My only reaction is WTF?!?!
Last edited by F657; 05 Dec 2023 at 06:36.
Not entirely sure, but I guess all the apps are "allowed" to be controlled by Windows Firewall, but then according to your second screenshots all these apps are blocked. I would nit worry. Just try whatever you want to do (such as blocking the application updating) and confirm it works.