Windows XP: firewall command line
The "netsh" command is useful for many network tasks. Because it can be used at the command line means it can be used in scripts.
The following command shows what firewall rules are currently applied to the system.
C:\>netsh firewall show service verbose = enable
The following is an example of setting a firewall rule with the command line. It will set the Remote Desktop service (port 3389) to answer only to IP 192.168.0.100
C:\>netsh firewall set service profile=ALL type=REMOTEDESKTOP mode=ENABLE scope=CUSTOM addresses=192.168.0.100