"Blocking Windows Firewall ports for testing" Firewall.win7.port.cn.bat

Source: Internet
Author: User

"Blocking Windows Firewall ports for testing" Firewall.win7.port.cn.bat

@echo  offrem v1.0.2color 2ftitle windows firewall Port blocking set dport=8000set direction= outgoto menu:menuset rule_name=block_tcp_%direction%_%dport%echo.echo          Menu:echo            1.  Add this rule:      echo                                     [Rule name:%rule_name%]echo                                     [Operation:  Blocking]echo                                     [Port: %dport%]echo                                     [direction: %direction%]echo             2.  Delete this rule:   echo                                     [Rule name: %rule_name%]echo             3.  setting a new port and direction: echo                                     [Default value:  port =8000,  Direction =out]echo            4.  Show this rule:      echo                                     [Rule name:  %rule_name%]echo            5.  Shows all rules with names beginning with Block_tcp:     echo                             The         [rule name:  begins with "Block_tcp"]echo             8.  Help echo             9.  menu echo            0.   Exit echo        _____________________________________________________________echo          Note 1: Select a number and press ENTER;echo.goto start:menu_helpecho.echo   how to: Echo.echo     →   Press 3 (Enter): Set parameters, such as,echo                            ports [8000]=9001 (carriage return) echo                            direction [out]= (carriage return) (i.e. default out);echo     →   Press 1 (Enter): Add New Rule "block_tcp_out_9001" to firewall;echo    →   Press 4 (Enter): Show current rule "Block_tcp_out_9001";echo    →   Press 2 (enter): Delete the current rule "block_tcp_out_9001";echo       repeat the above steps to operate the new rule;echo    →   Press 5 (carriage return): Shows all rules with names beginning with "Block_tcp" ; echo      before deleting, please confirm the current set port and direction. Echo.goto start:startecho.echo        [1 (New), 2 (delete), 3 (set), 4 (display), 5 ( Show All)]echo        ---------------------------------------------------- ---------set choice=set /p choice= Please select:echo.if /i  "%choice%" = "" " goto warnif  /i %choice%==1 goto rule_addif /i %choice%==2 goto rule_delif /i  %choice%==3 goto settingif /i %choice%==4 goto rule_showif /i % choice%==5 goto rule_show_allif /i %choice%==8 goto menu_helpif /i % choice%==9 goto menuif /i %choice%==0 goto end:warnecho  Warning! Invalid input, please re-select! & goto start:rule_addnetsh advfirewall firewall add rule name= "%rule_ Name% " dir=%direction% protocol=tcp remoteport=%dport% action=blockgoto staRt:rule_delnetsh advfirewall firewall del rule dir=%direction% name= "%rule_name% "goto start:rule_shownetsh advfirewall firewall show rule dir=%direction%  Name= "%rule_name%" goto start:rule_show_allnetsh advfirewall firewall show rule  dir=%direction% name=all|findstr block_tcpgoto start:settingset dport=8000set /p  dport= Port [8000]:echo %dport%|findstr  "[^0-9]" echo %dport%|findstr  "[^0-9]"  >  nul && goto setting | |  goto setting_2:setting_2set direction=outset /p direction= direction [out]:echo % direction%|findstr  "In out"  > nul && goto menu | |  goto setting_2:endexit


"Blocking Windows Firewall ports for testing" Firewall.win7.port.cn.bat

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.