欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Windows批量添加防火墻例外端口的批處理代碼

 更新時(shí)間:2012年11月10日 23:22:20   作者:  
有時(shí)候我們需要添加很多端口到防火墻例外,如果一個(gè)一個(gè)手工添加很累,那么就可以利用下面的方法
Windows批量添加防火墻例外端口

復(fù)制代碼 代碼如下:

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

下面的文章特色就是,如果是按順序的可以手工添加,也可以通過批處理 vbs js等批量輸出
例如:如下端口80,3389,4399,3001-3020....
就可以數(shù)組批量輸出更方便,就是下面的代碼了,具體的大家自己發(fā)揮吧

XP系統(tǒng)自帶防火墻批量添加端口到例外的簡(jiǎn)便方法

今天在一臺(tái)電腦上裝了一軟件,需要添加好幾十個(gè)端口到防火墻例外里.結(jié)果發(fā)現(xiàn)竟然只能一個(gè)一個(gè)添加.在網(wǎng)上找了些做法,都是用VBS來批量添加.兄弟我沒學(xué)過VBS,不會(huì)用,所以就只好想到用老朋友bat文件了.結(jié)果發(fā)現(xiàn)還真行,特把方法記下來,以備下次再用.
在bat里給防火墻添加端口的語句如下:
Netsh firewall set portopening udp/tcp/all port_number name enable
所以,為了節(jié)省時(shí)間和體力,先新建一個(gè)excel文檔,在里面寫好要添加的語句,如下圖:

在這里,我給端口起的名字叫做polycom-端口號(hào),然后選定所有記錄,復(fù)制到文本文檔里.并刪除名字中間的TAB符.這一步很容易,只是為了省點(diǎn)體力而已.如果不嫌麻煩,可以全部寫入到文本文檔里去,不過如果端口太多,工作量也不小.
然后把文本文檔保存成bat文件.內(nèi)容如下:
復(fù)制代碼 代碼如下:

@echo off
rem 下面添加要加入到例外的端口號(hào).這里使用all,表示TCP與UDP.如果只是tcp或UDP,可以改成相應(yīng)的.
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

做好后保存成bat文件就可以了,我這里保存成polycom_port_add.bat文件.
這樣,執(zhí)行此文件就大功告成了.
刪除的方法也很簡(jiǎn)單,把這個(gè)文件做一個(gè)備份,重命名,我這里改成polycom_port_del.bat.
然后修改內(nèi)容,把里面的set用delete代替(別告訴我誰不會(huì)用替換).然后把后面的名字和enable用空格代替.內(nèi)容如下:
netsh firewall delete portopening all 3230
........
以下如果要?jiǎng)h除那些端口,就可以直接這么用它了.

其實(shí)方法真是太簡(jiǎn)單,只是耗體力,所以決定用excel,而且可以搭配使用word(word可以方便替換特殊符號(hào)比如說制表符).這樣就容易多了.
見笑了.

相關(guān)文章

最新評(píng)論