Programmatically add rules to “Windows Firewall with Advanced Security snap-in”?

Is there any library in .NET that would allow me to manipulate the Windows Firewall with Advanced Security in Windows 7?

The reason I ask this is because, I want to be able to add program/port exceptions programmatically.

For example, I want to add program.exe to the Inbound Rules section and for this program, I want to allow TCP port 5660 and UDP port 5660. All other ports should be blocked for this program alone;

I reasoned that this could be comfortably set in the Inbound Rules Section in Windows Firewall with Advanced Security; I hope this is the best way of doing it?

However, how would I accomplish that programmatically?

I have already seen an example here, but I think this one talks about “Allow a program through Windows Firewall snap-in”, which does not have the port information.

Programmatically add IP to Server 2008 firewall rule

Anybody know how to programmatically add an IP address to a Server 2008 Windows Firewall with Advanced Security rule? i.e. I’ve setup a Block Action firewall rule which has some IP addresses listed un

Enable Windows Firewall (with Advanced Security) logging

Which is the equivalent of: netsh advfirewall set currentprofile logging filename %systemroot%/system32/LogFiles/Firewall/pfirewall.log in C/C++ and VBScript ? I found nothing in official: Windows Fi

Programmatically modify Firewall rules in Windows Server 2008 R2

I want be able to programmatically enable, disable, create firewall rules in Windows Server 2008 R2. What is the object model to modify the firewall rules from .Net/PowerShell?

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 WindowsFirew

Programmatically add an application to Windows Firewall

I have an application that is installed and updated via ClickOnce. The application downloads files via FTP, and therefore needs to be added as an exception to the windows firewall. Because of the way

Enumerate connections with Windows Firewall with Advanced Security API

Using the deprecated Internet Connection Sharing and Internet Connection Firewall API, it is possible to enumerate the connections with INetConnectionProps interface. See sample code here. What is th

Programmatically add an windows service to Windows Firewall (During Installation) [duplicate]

Possible Duplicate: Programmatically add an application to Windows Firewall in my solution i have an windows service project and installer to install this service How i can add this service to Windo

Programmatically modify firewall rules Linux

I need to assign rules in my firewall using programming.. I mean I want to create a web app in which user can select the firewall rules for their ip address and those rules will be assigned to that IP

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

Windows firewall rule for XP

How to programmatically add an application or port to Windows Firewall on Windows XP?