We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

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

Reece
Reece asked
on
Medium Priority
4,575 Views
Last Modified: 2012-05-11
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.
Comment
Watch Question

David Johnson, CDSimple Geek from the '70s
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
instead of netsh firewall you need to use netsh advfirewall firewall as shown here
ReeceICT Consultant
CERTIFIED EXPERT

Author

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.

Simple Geek from the '70s
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
ReeceICT Consultant
CERTIFIED EXPERT

Author

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
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.