bitrazor.com ...THE source for mediocre content                                      

TiVo HME How-To: Create a Windows Firewall Exception for your Service

If you followed the how-to on creating a Windows service for your application, there's one last thing you need to do: create an exception for it in Windows Firewall.

Windows Firewall is an evolution of the Internet Connection Firewall that's been in Windows XP for a while.  Windows Firewall is enabled by default in Windows XP Service Pack 2.

For applications installed as a service, they'll install and start up fine; however, Windows Firewall will block them, so your TiVo will never be able to run them.  They'll show up in the list, but they'll hang when you try to access them, and they'll eventually time out.

If you're executing an application by hand that needs network access, Windows Firewall will pop up a dialog box, asking you what you want to do, and you can click 'Unblock'.  For applications deployed as a Windows Service, however, this is not the case -- the user is never prompted to unblock.

So, you have to add an exception when you first install the service.   This turns out to be really easy.  Take a look at my examples from my TrafficCam application, and you should be able to modify them to fit your application.

bullet My service install script, calling the "FirewallExceptionAdd.vbs" script
bullet FirewallExceptionAdd.vbs, the script that actually adds the exception
bullet My service uninstall script, which calls "FirewallExceptionRemove.vbs"
bullet FirewallExceptionRemove.vbs, which removes the exception

If you're modifying this for your own use, there are a few things to note:

  • FirewallExceptionAdd.vbs takes one command-line parameter, then name of the .exe to be added as an exception.
  • The .exe must be in the same directory as FirewallExceptionAdd.vbs.
  • There's one line you'll need to edit in FIrewallExceptionAdd.vbs:
    • app.Name = "TiVo: TrafficCam Viewer Service"

Change app.Name to the descriptive name of your application.

Scope

By default, the Windows Firewall exception is added as 'My Network (subnet) only' by FirewallExceptionAdd.vbs:

This is the recommended setting for most installs.  You can change this setting by doing Start - Control Panel - Windows Firewall.  Click the 'Exceptions' tab, then find 'TiVo: TrafficCam Viewer Service' in the list.  Click 'Edit...', then 'Change Scope...'  You should see the dialog box above.

More Info on Windows Firewall

bullet Windows Firewall API page from Microsoft -- a good reference
                                                         Last updated: August 7, 2009