How to create a batch file to turn Windows firewall off and on

Q: The client run FTP passive mode and need to turn open port rang fr om 1024 to 65535. They would like to create a batch file to do so. How?

A: These are some example to useful command for turning firewall on/off and showing status:

netsh advfirewall show allprofiles

netsh advfirewall set currentprofile state on

netsh advfirewall set currentprofile state off

netsh advfirewall firewall add rule name=”Open Remote Desktop” protocol=TCP dir=in localport=3389 action=allow

Since running these command may need run as admin, You can use a shortcut that links to the batch file. Just go into properties for the shortcut and select advanced, then “run as administrator”.

Published by

Bob Lin

Bob Lin, Chicagotech-MVP, MCSE & CNE Data recovery, Windows OS Recovery, Networking, and Computer Troubleshooting on http://www.ChicagoTech.net How to Install and Configure Windows, VMware, Virtualization and Cisco on http://www.HowToNetworking.com