Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

In Windows Firewall with Advanced Settings I can create a rule which blocks all inbound or outbound traffic for particular program by pointing to its .exe file. The problem is that this program has many .exe files in its directory, as well as additional ones in its sub directories. So many question is: do I need to make separate rules for each .exe file, which in this case would mean about 50 rules or is there a way to block the traffic for a group of .exe files based on their location on the local hard drive. Thank you.

share|improve this question
Might be worth investigating which of the 50 files handles network traffic. –  Mark C. Wallace Nov 27 '12 at 11:39
@MarkC.Wallace, And how would you even do that assertatively? –  Pacerier 2 days ago

3 Answers 3

up vote 1 down vote accepted

*Configure and Add rules in windows firewall based on dynamic content (exe files) in that folder: *

you should work with PowerShell or command line tools that run everyday.

like this : Article Link

function Add-FirewallRule {
      $appName = $null,
      $serviceName = $null
    $fw = New-Object -ComObject hnetcfg.fwpolicy2 
    $rule = New-Object -ComObject HNetCfg.FWRule

    $rule.Name = $name
    if ($appName -ne $null) { $rule.ApplicationName = $appName }
    if ($serviceName -ne $null) { $rule.serviceName = $serviceName }
    $rule.Protocol = 6 #NET_FW_IP_PROTOCOL_TCP
    $rule.LocalPorts = $tcpPorts
    $rule.Enabled = $true
    $rule.Grouping = "@firewallapi.dll,-23255"
    $rule.Profiles = 7 # all
    $rule.Action = 1 # NET_FW_ACTION_ALLOW
    $rule.EdgeTraversal = $false

# Sample Usage
Add-FirewallRule "Test port 1234" "1234" $null $null
Add-FirewallRule "Test port 5555-6666" "5555-6666" $null $null
Add-FirewallRule "Test port 2222 Calc" 2222 "c:\windows\system32\calc.exe" $null
Add-FirewallRule "Test port 3333 W3SVC" 3333 $null "W3SVC"

There are also some good VBScript samples on MSDN which I used as a starting point.

BUT recommended that you add firewall or proxy in edge of your network, like ISA or SQUID for all of your inbound traffic in your LAN.

open ISA Server Management, click Start, point to All Programs, point to Microsoft ISA Server, and then click ISA Server Management.

Block responses containing Windows executable content visit this Article here

To block responses containing Windows executable content 

 1. In the console tree of ISA Server Management, click Firewall Policy.

 2. In the details pane, click the applicable access rule or Web
        publishing rule.
 3. On the Tasks tab, click Edit Selected Rule.
 4. On the Traffic tab (for Web publishing rules) or on the Protocols
        tab (for access rules), click Filtering, and then click Configure
 5. On the General tab, click Block responses containing Windows
        executable content.

in our network that based on windows we have cache server named SQUID :

Squid content filtering: Block / download of music MP3, mpg, mpeg, exec files

  1. First open squid.conf file /etc/squid/squid.conf:

    vi /etc/squid/squid.conf

  2. Now add following lines to your squid ACL section:

    acl blockfiles urlpath_regex "/etc/squid/blocks.files.acl"

  3. You want display custom error message when a file is blocked:

    Deny all blocked extension

    deny_info ERR_BLOCKED_FILES blockfiles

    http_access deny blockfile

share|improve this answer

If the .exe's are located in the same folder you can probably add it in the windows firewall list.If they are located in different folders then you have to manually add those.In general,the firewall will ask for user's permission if an .exe tries to access the network i.e one that is not recognized as a trusted application.But it wont track what are the individual exe's that are called inturn by that process.You can either disable all ports or specific ports.

In general the windows firewall is not my recommendation unless you update your windows everyday.Use Comodo's free edition to have better control and it can be easily setup.

share|improve this answer
If the .exe's are located in the same folder you can probably add it in the windows firewall list. How - I am only able to add one .exe per rule, but I can't find an option to add a whole folder containing .exes to a rule. –  Alex Popov Nov 27 '12 at 14:25

Here's a simplier way: https://sites.google.com/site/mytools4000/home/allow-block-multiple-programs-through-windows-7-firewall

Although @saber tabatabaee yazdi answer is much more thorough.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.