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

27,336

Greg's answer in this question helped me.

Any way to turn the "internet off" in windows using c#?

Share:
27,336

Related videos on Youtube

Santhosh
Author by

Santhosh

Am currently working in Philips. Like most things computing. Especially Algorithms, Mathematics, NLP, Operating Systems. I use .NET framework for daily programming.. Looking for that divine touch yet to cross the boundary...

Updated on July 09, 2022

Comments

  • Santhosh
    Santhosh almost 2 years

    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.

  • Gyuri
    Gyuri over 12 years
    Indeed, that answer is totally covering this question. Would that qualify this post as duplicate?