Windows bulk Add firewall exception port
Copy Code code as follows:
echo off
Cls
Set var=30000
Set end=30010
: Continue
set/a var+=1
echo Add Port%var%
netsh firewall add portopening TCP%var% ftp_data_%var%
If%var% LSS%end% Goto Continue
Echo Complete
Pause
The following article features, if the order can be manually added, can also be batch processing VBS JS, such as bulk output
For example: The following port 80,3389,4399,3001-3020 ....
Can be the array of batch output more convenient, is the following code, the specific everyone to play it
XP system with firewall to add ports to the exception of the simple method
Today, I installed a software on a computer, you need to add dozens of ports to the firewall exception. It turns out that you can only add one one. I found some ways to do it on the Internet, using a VBS to bulk Add. Brother I have not learned VBS, will not use, so I had to think of old friend bat file. Write down the method for the next time.
The statement to add a port to the firewall in BAT is as follows:
Netsh Firewall set portopening udp/tcp/all port_number name enable
So, in order to save time and energy, create a new Excel document, in which to add statements, the following figure:
Here, the name I give to the port is called the polycom-port number, then select all the records and copy them to the text document. and remove the tab character in the middle of the name. This step is easy, just to save some energy. If it's not too much trouble, you can write it all into a text document, but if there are too many ports, The workload is also not small.
The text document is then saved as a bat file. The contents are as follows:
Copy Code code as follows:
@echo off
REM Add the port number you want to add to the exception. Use all to represent TCP and UDP. If only TCP or UDP, you can change to the appropriate.
netsh firewall set portopening all 3230 polycom-3230 enable
netsh firewall set portopening all 3231 polycom-3231 enable
netsh firewall set portopening all 3232 polycom-3232 enable
netsh firewall set portopening all 3233 polycom-3233 enable
netsh firewall set portopening all 3234 polycom-3234 enable
netsh firewall set portopening all 3235 polycom-3235 enable
netsh firewall set portopening all 3236 polycom-3236 enable
netsh firewall set portopening all 3237 polycom-3237 enable
netsh firewall set portopening all 3238 polycom-3238 enable
netsh firewall set portopening all 3239 polycom-3239 enable
netsh firewall set portopening all 3240 polycom-3240 enable
netsh firewall set portopening all 3241 polycom-3241 enable
netsh firewall set portopening all 3242 polycom-3242 enable
netsh firewall set portopening all 3243 polycom-3243 enable
netsh firewall set portopening all 3244 polycom-3244 enable
netsh firewall set portopening all 3245 polycom-3245 enable
netsh firewall set portopening all 3246 polycom-3246 enable
Exit
After you have done it, save it as a bat file and I'll save it as a Polycom_port_add.bat file.
This way, the execution of this file is accomplished.
The method of deletion is also very simple, make a backup of this file, rename, I change here to Polycom_port_del.bat.
Then modify the contents and replace the inside set with the delete (Don't tell me who won't use the replacement). Then replace the name and enable with a space. The contents are as follows:
netsh firewall delete portopening all 3230
........
The following if you want to remove those ports, you can use it directly.
In fact, the method is too simple, just physical exertion, so decided to use Excel, but also can use Word (Word can easily replace special symbols such as tabs). That's easier.
laughed.