The method is not original, its described in many places. This was described in a posting here.
Step 1 - save the following to blockit.bat
if "%1"=="list" (
netsh advfirewall firewall show rule Blockit | findstr RemoteIP
:: Deleting existing block on ips
netsh advfirewall firewall delete rule name="Blockit"
:: Block new ips (while reading them from blockit.txt)
for /f %%i in (blockit.txt) do (
netsh advfirewall firewall add rule name="Blockit" protocol=any dir=in action=block remoteip=%%i
netsh advfirewall firewall add rule name="Blockit" protocol=any dir=out action=block remoteip=%%i
:: call this batch again with list to show the blocked IPs
call %0 list
Step 2 - save a list of IP addresses to blockit.txt
Step 3 - run the batchfile
a. [to read] blockit.txt and block ip addresses
c:\> blockit.bat blockit.txtb. [to list] the ip addresses currently blocked
c:\> blockit.bat listc. [to unblock] all of the ip addresses that were blocked
c:\> netsh advfirewall firewall delete rule name="Blockit"