@echo off
mode con: cols=85 lines=30
:sanpang
title  端口放行  
color 0A
cls
echo.                   
echo.                      
echo -------------------------------  端口放行  -----------------------------------
echo.                                                                         
echo.       
echo    * 此工具可设置允许常用端口通过防火墙，不需其他操作。
echo.                                                                     
echo.
echo.     
echo    * 必须以系统管理员身份运行，以下提供此工具所做的操作的介绍：
echo.
echo       1：允许80端口 2：允许443端口 3：允许21端口 4：允许8080端口 5：允许8888端口
echo       6.允许25端口      
echo.  
echo       7: 退出                                                              
echo                                                      v1.0                      
echo                                                      
echo                                                                  
echo --------------------------------------------------------------------------
echo.
set start=
set /p start=    输入(1 2 3 4 5 6)后按回车键:
if "%start%"=="1" goto 80
if "%start%"=="2" goto 443
if "%start%"=="3" goto 21
if "%start%"=="4" goto 8080
if "%start%"=="5" goto 8888
if "%start%"=="6" goto 25
if "%start%"=="7" goto quit
goto sanpang

:80
netsh advfirewall set currentprofile state on > nul
netsh advfirewall firewall add rule name="80TCP" dir=in action=allow localport=80 remoteip=any protocol=tcp > nul
netsh advfirewall firewall add rule name="80UDP" dir=in action=allow localport=80 remoteip=any protocol=udp > nul
echo ---------------------------------------------------------------------------------
echo    *  允许80端口命令执行完毕！
echo .
pause
goto sanpang
:443
netsh advfirewall set currentprofile state on > nul
netsh advfirewall firewall add rule name="443TCP" dir=in action=allow localport=443 remoteip=any protocol=tcp > nul
netsh advfirewall firewall add rule name="443UDP" dir=in action=allow localport=443 remoteip=any protocol=udp > nul
echo ---------------------------------------------------------------------------------
echo    *  允许443端口命令执行完毕！
echo .
pause
goto sanpang
:21
netsh advfirewall set currentprofile state on > nul
netsh advfirewall firewall add rule name="21TCP" dir=in action=allow localport=21 remoteip=any protocol=tcp > nul
netsh advfirewall firewall add rule name="21UDP" dir=in action=allow localport=21 remoteip=any protocol=udp > nul
echo ---------------------------------------------------------------------------------
echo    *  允许21端口命令执行完毕！
echo .
pause
goto sanpang

:8080
netsh advfirewall set currentprofile state on > nul
netsh advfirewall firewall add rule name="8080TCP" dir=in action=allow localport=8080 remoteip=any protocol=tcp > nul
netsh advfirewall firewall add rule name="8080UDP" dir=in action=allow localport=8080 remoteip=any protocol=udp > nul
echo ---------------------------------------------------------------------------------
echo    *  允许8080端口命令执行完毕！
echo .
pause
goto sanpang

:8888
netsh advfirewall set currentprofile state on > nul
netsh advfirewall firewall add rule name="8888TCP" dir=in action=allow localport=8888 remoteip=any protocol=tcp > nul
netsh advfirewall firewall add rule name="8888UDP" dir=in action=allow localport=8888 remoteip=any protocol=udp > nul
echo ---------------------------------------------------------------------------------
echo    *  允许8888端口命令执行完毕！
echo .
pause
goto sanpang
:25
netsh advfirewall set currentprofile state on > nul
netsh advfirewall firewall add rule name="25TCP" dir=in action=allow localport=25 remoteip=any protocol=tcp > nul
netsh advfirewall firewall add rule name="25UDP" dir=in action=allow localport=25 remoteip=any protocol=udp > nul
echo ---------------------------------------------------------------------------------
echo    *  允许25端口命令执行完毕！
echo .
pause
goto sanpang