Skip to content

Instantly share code, notes, and snippets.

@Shterneregen
Created March 26, 2020 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shterneregen/679d7235933401761a2c46cbd5d861e1 to your computer and use it in GitHub Desktop.
Save Shterneregen/679d7235933401761a2c46cbd5d861e1 to your computer and use it in GitHub Desktop.
Open / Close port in Windows via BAT (CMD)
@echo off
set /p port=Close port:
netsh advfirewall firewall delete rule name="Port%port%"
echo %port% port closed
pause
@echo off
set /p port=Open port:
netsh advfirewall firewall add rule name="Port%port%" protocol="TCP" localport=%port% action=allow dir=IN
echo %port% port opened
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment