in reply to Re^2: Register with XP Service Pack 2 Firewall
in thread Register with XP Service Pack 2 Firewall

This is how I ended up solving the problem..
Note: I try 5 times so that this script can be put in startup. Without the retry, the script may run before the firewall has initialized.
use strict; my $count=0; my $ok=0; my $progname=shift || usage(); my $progexe=shift || usage(); while(1){ $ok=&registerFirewall($progname,$progexe); last if $ok; last if $count>5; $count++; sleep(5); } if(!$ok){die "Unable to register with windows firewall.\n";} ############### sub usage{ print "$0 Name PathToExe\n"; print "\tRegisters program Name found at PathToExe with Windows Fi +rewall\n"; exit; } ############### sub registerFirewall{ my $name=shift || return "No Name"; my $path=shift || return "No Path"; return "$path does not exist" if !-s $path; my $cmd=qq|netsh firewall add allowedprogram "program=$path" "name +=$name"|; #print "$cmd\n"; my @tmp=`$cmd`; my $result=join('',@tmp); if($result=~/ok/is){return 1;} print "registerFirewall Error: $result\n"; return 0; }