• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3488
  • Last Modified:

Batch file or script to allow ports and programs in Win7 Firewall

I have a number of TCP and UDP ports and a few exe's that need to be allowed for both inbound and outbound in the windows 7 (pro) firewall.
I've got 7 new PC's to build up and was wondering if there was a script or batch file I could modify to run on each PC.  
I used to have one for our WinXP systems, but this won't work on the Win7 firewall.

Thanks in advance.
0
Reece Dodds
Asked:
Reece Dodds
  • 2
  • 2
1 Solution
 
David Johnson, CD, MVPOwnerCommented:
instead of netsh firewall you need to use netsh advfirewall firewall as shown here
0
 
Reece DoddsAuthor Commented:
so...  adding ports is done with what string???


for the XP script I was using:

echo Adding firewall exception for TCP Port 50808.
netsh advfirewall firewall add portopening protocol=TCP port=50808 name="Avaya Port 50808 TCP" mode=ENABLE scope=ALL profile=ALL

I gather this will be different for Win7 because of inbound and outbound rules and private/public networks.

0
 
David Johnson, CD, MVPOwnerCommented:
netsh advfirewall firewall add rule name=”My Application” dir=in action=allow program=”C:\MyApp\MyApp.exe” enable=yes remoteip=157.60.0.1,172.16.0.0/16,LocalSubnet profile=domain
profile can be public/private/domain/all
netsh advfirewall firewall add rule name=”Open Port 80” dir=in action=allow protocol=TCP localport=80
or for your example
netsh advfirewall firewall add rule name="Avaya Port 50808 TCP" dir=in action=allow protocol=TCP port=50808
0
 
Reece DoddsAuthor Commented:
Slight typo...

or for your example
netsh advfirewall firewall add rule name="Avaya Port 50808 TCP" dir=in action=allow protocol=TCP port=50808

Should've bene localport
But otherwise perfect for what i need.
thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now