Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save richinseattle/371a2c5cde98505c883c1aae7a54e4bb to your computer and use it in GitHub Desktop.
Save richinseattle/371a2c5cde98505c883c1aae7a54e4bb to your computer and use it in GitHub Desktop.
@echo off
:: shields.bat - block all inbound connections on boot or with 'up' and 'down' commands
:: save somewhere permanent and run 'shields.bat install' to raise shields on boot
goto argparse
:up
netsh advfirewall set %FW_PROFILE% firewallpolicy blockinboundalways,allowoutbound
EXIT /B
:down
netsh advfirewall set %FW_PROFILE% firewallpolicy blockinbound,allowoutbound
EXIT /B
:install
set SHIELDS_BAT=%~fp0
schtasks /create /tn "shields.bat" /tr %SHIELDS_BAT% /sc onstart /rl highest /ru system
EXIT /B
:uninstall
schtasks /delete /tn "shields.bat"
EXIT /B
:argparse
set FW_PROFILE=currentprofile
if "%2"=="all" set FW_PROFILE=allprofiles
if "%2"=="current" set FW_PROFILE=currentprofile
if "%2"=="domain" set FW_PROFILE=domainprofile
if "%2"=="global" set FW_PROFILE=global
if "%2"=="private" set FW_PROFILE=privateprofile
if "%2"=="public" set FW_PROFILE=publicprofile
if "%1"=="" goto up
call :%1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment