How to block multiple EXE files Windows Firewall

Page 2 of 3 FirstFirst 123 LastLast

  1. Posts : 4
    Windows 10
       #11

    jpeni said:
    Use this batch file to add exe and dll files to Firewall in Windows 10

    Problem is: when you run this batch file as Admin

    it asks whether you want to block Windows/System32 and all its subfolders---NOT EXACTLY WHAT MOST EVERYONE WOULD DESIRE !
    Last edited by Brink; 11 Jan 2018 at 17:38. Reason: fixed quote box
      My Computer


  2. Posts : 4
    Windows 10
       #12

    ARC1020 said:
    Windows Firewall doesn't support wildcards, therefore I'm thinking using a batch file would probably be the quickest way. Batch files aren't really my forte, however as an example maybe something along these lines.

    1) Paste ALL the following into NotePad (including the last line that's hidden from view) and obviously edit to show the folder path where the applications that you want to block are.

    Code:
    for %%G in ("C:\Program Files (x86)\Test Folder\*.exe") do (
    
    netsh advfirewall firewall add rule name="Blocked With Batchfile %%G" dir=in action=block program="%%G" enable=yes profile=any
    netsh advfirewall firewall add rule name="Blocked With Batchfile %%G" dir=out action=block program="%%G" enable=yes profile=any
    
    )

    2) Save the text file and rename it to BlockInOut.bat
    .
    .
    .
    .
    .
    etc. etc.

    Tried all of that....didn't do anything...no rules were added.

    EDIT:
    OOOPPSS !! My bad....I didn't try refreshing the rules page ! IT DOES WORK THOUGH!! GREAT THANKS
    Last edited by Brink; 11 Jan 2018 at 17:39. Reason: fixed quote box
      My Computer


  3. Posts : 4
    Windows 10
       #13

    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
      My Computer


  4. Posts : 4
    Windows 10
       #14

    Actually some one already did that:
    https://sites.google.com/site/mytool...ws-7-firewall/
      My Computer


  5. Posts : 3
    Windows 10 rs3
       #15

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


  6. Posts : 3,513
    Windows 10 Pro 64-bit 21H1 (May 2021 build 19043.1083)
    Thread Starter
       #16

    MaicoRossoni said:
    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!
    You don't have to create a bat file. You save the script file on a USB flash drive (see previous posts how to create it) and then you simply run it as Administrator.
      My Computer


  7. Posts : 3
    Windows 10 rs3
       #17

    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
      My Computer


  8. Posts : 3
    Windows 10 rs3
       #18

    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
      My Computer


  9. Posts : 3
    Win 10 LTSC v.1809
       #19

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

    How to block multiple EXE files Windows Firewall-1.jpg
    How to block multiple EXE files Windows Firewall-2.jpg
    Last edited by F657; 05 Dec 2023 at 06:36.
      My Computer


  10. Posts : 3,513
    Windows 10 Pro 64-bit 21H1 (May 2021 build 19043.1083)
    Thread Starter
       #20

    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.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 01:05.
Find Us




Windows 10 Forums