国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > BAT > 正文

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

2020-06-09 13:54:20
字體:
來源:轉載
供稿:網友
Windows批量添加防火墻例外端口

代碼如下:
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....
就可以數組批量輸出更方便,就是下面的代碼了,具體的大家自己發揮吧

XP系統自帶防火墻批量添加端口到例外的簡便方法

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

在這里,我給端口起的名字叫做polycom-端口號,然后選定所有記錄,復制到文本文檔里.并刪除名字中間的TAB符.這一步很容易,只是為了省點體力而已.如果不嫌麻煩,可以全部寫入到文本文檔里去,不過如果端口太多,工作量也不小.
然后把文本文檔保存成bat文件.內容如下:
代碼如下:
@echo off
rem 下面添加要加入到例外的端口號.這里使用all,表示TCP與UDP.如果只是tcp或UDP,可以改成相應的.
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文件.
這樣,執行此文件就大功告成了.
刪除的方法也很簡單,把這個文件做一個備份,重命名,我這里改成polycom_port_del.bat.
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 高雄市| 景宁| 德昌县| 蒙山县| 台北市| 万全县| 海原县| 霍山县| 麻城市| 黎城县| 金门县| 屏山县| 民丰县| 房产| 酉阳| 南靖县| 甘泉县| 定结县| 武冈市| 阳高县| 汶上县| 塘沽区| 义马市| 临泽县| 嫩江县| 龙陵县| 隆化县| 若尔盖县| 长宁区| 钟山县| 徐水县| 万源市| 滨州市| 枣阳市| 喀喇沁旗| 锦州市| 栾川县| 云安县| 固原市| 集安市| 读书|