Needed to open a big range of ports on Windows Firewall on one of my web boxes. Via the GUI you can only do one port at a time. But run this at the command prompt to add a range:
FOR /L %I IN (5001,1,5201) DO netsh firewall add portopening TCP %I "Passive FTP"%I
This opens ports 5001 to 5201, and names them 'Passive FTP'.
Found this here.
Oh, takes time, like a port or two a second, so if you have a wide range it's going to take some time.

Hey,
I'm having trouble with your command prompt solution and this is whats happening:
I copy your solution:
FOR /L %I IN (6881,1,6999) DO netsh firewall add portopening TCP %I "Passive FTP"%I
I paste it in to command prompt and I see it working on each individual port but it says:
"netsh is not recognized as an internal or external command, operable program or batch file."
and doesn't open them and when I go to my firewall exceptions they are not their so please help me and I'm not particularly great with technology so please bear with me
Thanks a lot
Posted by: Jiggie | October 19, 2011 at 06:07 AM
Hi Jiggie
NETSH is the program that's doing the actual opening of the ports. By the sound of things it's not in the default system directory. I would check:
C:\WINDOWS;
C:\WINDOWS\system32
And see if you can find it (maybe just search whole machine).
If you locate it, then reference it directly with the path to the program file, for example:
FOR /L %I IN (6881,1,6999) DO C:\WINDOWS\netsh firewall add portopening TCP %I "Passive FTP"%I
Kind regards...David
Posted by: David Eedle | October 19, 2011 at 08:25 AM
Very useful thank you for posting this!
Posted by: jang | December 23, 2011 at 04:26 AM
Super helpful, thanks!
Posted by: Justin | January 09, 2012 at 03:01 AM
big help, thank you!
Posted by: John | February 22, 2012 at 08:44 AM
To open a range of ports you don't need to add one rule per port - you can do it with just one rule. E.g. this will open 64000-64005 TCP inbound:
netsh advfirewall firewall add rule name="My Port Range Rule" dir=in protocol=tcp localport=64000-64005 action=allow
Posted by: Bart Duncan | April 26, 2012 at 06:29 AM
This was very useful and saved me alot of work, thanks alot :)
Posted by: Daniel | May 09, 2012 at 04:27 AM