08 Jun 2009

Add a Firewall exception at install time using WiX

Windows Firewall

Although I’m not a heavy user of WiX, I’ve been using it for years to build my install packages. I’ve followed a couple of times the tutorial and then tweaked my source files from there.

I’m planning a new feature to one of my apps that basically will send UDP messages through the network in order to keep all the clients in sync. This of course will require a firewall exception.i

I don’t want my users to configure the Windows Firewall by themselves if possible so I did a quick search and found that exists a WiX Firewall extension that does exactly what I need. It couldn’t be easier, adding just this line to my script and passing the appropriate dll to candle and light did the trick.

<FirewallException Id="FWX1" Name="Panel" Scope="localSubnet"
        xmlns="http://schemas.microsoft.com/wix/FirewallExtension" /> 

By the way, I’ve tested it with the Windows Firewall set to Off and the exception is added anyway, so if the user turns it on the exception is already there. Unfortunately it doesn’t work if the Firewall service is not started. Adding the attribute IgnoreFailure=”yes” to the previous code will avoid an error message.

Also if the user has a third-party firewall I’m pretty much in the starting row. However I hope this won’t be the setup of most of my clients.