Questions tagged [windows-firewall-api]
59 questions
13
votes
2 answers
Using Windows Firewall programmatically
I have difficulties to find anything related to Windows firewall (about how to add aplications to except list, close ports or disable internet access to some applications) in C++. I found even MS site shows examples in Visual Basic.
Where I can find…

user436550
- 131
- 1
- 1
- 4
8
votes
1 answer
Add a firewall rule for Distributed Transaction Coordinator (msdtc.exe)
I tried to use firewallAPI.dll to add a rule. It works fine for calc.exe (or some other files) as described bellow but fails for msdtc.exe with the following exception:
System.IO.FileNotFoundException: 'The system cannot find the file
specified.…

Serg046
- 1,043
- 1
- 13
- 42
8
votes
4 answers
Adding an application firewall rule to both private and public networks via win7 FirewallAPI
A little background: Basicaly I'd like to add a program firewall access rule to both private and public networks.
I used to use this-
"netsh firewall add allowedprogram program= "Path.." name=AppName ENABLE scope=ALL profile=CURRENT"
But now I'd…

Oyiwai
- 449
- 1
- 3
- 20
8
votes
6 answers
How can I detect if a firewall product is enabled?
How can I detect (from a Windows Forms application written in C#) if a firewall product is enabled?
Here is my code and i am getting error on INetFwMgr that type or namespace could not found
namespace WindowsFormsApplication1
{
public partial…

Pavan Anadkat
- 81
- 1
- 5
5
votes
1 answer
Controlling Windows Firewall in C# for Windows 7 and Xp Sp3
I here have a code working perfect in Windows 7 i took help from this post....
The problem comes when that same code in compiled on Win Xp Sp3 PC. Its does not comile... says interface missing (error) ....
I cant seem to figure out. I have added…

Ankesh
- 4,847
- 4
- 38
- 76
5
votes
1 answer
Disable the programs ability to add exceptions to windows firewall via the API
This is a problem with Windows Firewall that is very annoying from its introduction. And persist trough several versions of windows.
I have two questions:
Is it possible to be disabled or at least require confirmation in XP/2003 Server ?
Does UAC…
Daniel Iankov
4
votes
1 answer
What is an app container on Windows?
I am trying to debug a code which uses NetworkIsolationEnumAppContainers(). The document of the function says,
"The NetworkIsolationEnumAppContainers function enumerates all of the app containers that have been created in the system."
What does…

Sahil Singh
- 3,352
- 39
- 62
4
votes
0 answers
Add to windows firewall exception in standard user
I am trying to add an application to windows firewall exception.
I don’t want to give admin privileges to the EXE.
I tried netsh command as below.
netsh advfirewall firewall add rule name="Myapp" dir=in action=allow program=”C:\Program…

IT researcher
- 3,274
- 17
- 79
- 143
3
votes
1 answer
Memory leak when using NetFwTypeLib in .Net Core 3.1
I tracked down a memory leak in this IDS/IPS traffic monitor console app I've been working on. I thought it was entity framework, turns out it's the firewall code. The following code worked perfectly fine in .net 4.6.2 and it works mostly fine in…

Sum None
- 2,164
- 3
- 27
- 32
3
votes
2 answers
CommandLine IP block / unblock in Windows Firewall with Advanced Security
I'd like to programmatically be able to block outgoing packets to some IPs. Nevermind the application, I would like to be able to do it.
I have Windows 7 x64 Professional so it comes with WindowsFirewall with Advanced Security which has an outbound…

McTrafik
- 2,843
- 3
- 29
- 31
3
votes
1 answer
Setting Port Firewall Exceptions in Windows 10 Using C#
I'm trying to set a firewall exception for Windows 10. After doing numerous searches, I put together this code:
private const string PROGID_OPEN_PORT = "HNetCfg.FWOpenPort";
private const string CLSID_FIREWALL_MANAGER =…

Steve Graber
- 297
- 1
- 4
- 15
3
votes
1 answer
Creating a rule with the Windows Firewall API that applies to all applications run by a service
I'm trying set up a firewall rule for a Windows service to deny all inbound and outbound TCP and UDP connections except a whitelist of hosts and ports using the Windows Service Hardening API, following the VBScript example here.
Now, this service…

mpeac
- 720
- 8
- 27
3
votes
0 answers
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) in INetFwServices using NET_FW_SERVICE_REMOTE_DESKTOP type
I am trying to iterate within INetFwServices elements in Windows 10. However when I access to item Service Name: "Remote Desktop" Type: NET_FW_SERVICE_REMOTE_DESKTOP the application throws an exception Catastrophic failure (Exception from HRESULT:…

juancalbarran
- 61
- 5
3
votes
1 answer
Adding firewall exceptions for other firewall products than Windows Firewall - such as Norman, Norton etc
I have a WiX installer project where I have added two firewall exceptions as part of the installer by using the WiX FirewallException. This works great when the client machine is using Windows Firewall, but I got a report that a user failed to get…

tronda
- 3,902
- 4
- 33
- 55
3
votes
1 answer
Porting a C# application to Mono, need to use FirewallAPI. Is there a Mono equivalent?
I have written a Windows service that I am needing to port over to Mono so it can be used on Mac / Linux platforms.
It makes use of the FirewallAPI.dll (I think that is the actual name...). The other names are NetFwTypeLb, NATUPNPLib and…

Madeline
- 645
- 1
- 9
- 19