I have a service (say BS.exe) written using C# of which the installer is created using Wix and C# (which means it has a Custom Action program associated with the Wix installer program as well). Now, after the program in installed there is a need to go to Windows Firewall settings and register the BS.exe there. That is, go to Windows Firewall -> Change Settings -> Exceptions tab and add BS.exe there.

However, now we need to do this process automatically during the installation time. I guess the Custom Action program associated with the Wix is the best place. So is there a way to register this EXE as a Firewall exception using C#?

Thanks in advance!

8 Years
Discussion Span
Last Post by privatevoid

privatevoid, thanks a lot.

It works fine. However, I am encountering a problem that needs to be solved. That is, the "NetFwTypeLib" object resides in hnetcfg.dll in XP while it is inside the FirewallAPI.dll in Vista.

Since I need my application be authorized irrespective of the OS, how am I to tackle that problem? I cannot use both the .dlls can I? And it is a must that one code should be able to do this.


I would just check what OS (Environment.OSVersion) the application is running on and then decide in code which dll to look for.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.