Batch findstr with quotes
Posted: 23 Nov 2012 13:45
I'm trying to figure out how to modify this script to make exact searches. I need to search for a string (eg: "123.12" -- with quotes)
I'm trying to modify a Firewall Batch Script to block certain IP's
This is the script
This is the blocked IP file: http://pastebin.com/cP4BteDM
Now, trying to block, for example, 10.02.0, I'm receiving in console "10.02.02". I guess because 10.02.0 is "instr" "10.02.02". With this problem in the FINDSTR sentence, I will never be able to ban "10.02.0" for example.
Thank you in advance !!
I'm trying to modify a Firewall Batch Script to block certain IP's
This is the script
Code: Select all
ipconfig | findstr "Address" | qut -d: -f 2 | qni > %systemdrive%\Qaas\host_ip.txt
findstr \"%1\" %systemdrive%\Qaas\bin\host_ip.qas || findstr \"%1\" %systemdrive%\Qaas\white_list.txt || findstr \"%1\" %systemdrive%\Qaas\blocqedips.qas
IF %ERRORLEVEL% GTR 0 (
echo "NOT FOUND"
netsh ipsec stat add filter filterlist="IP List" srcaddr=%1 dstaddr=Me description=%1 protocol=any mirrored=yes
echo Blocked IP address %1, reason - %2 connections on %3 >> %systemdrive%\Qaas\Qaas-%dw%-%mm%-%dd%-%hh%.log
echo %1 >> %systemdrive%\Qaas\blocqedips.qas
) ELSE (
echo "FOUND"
echo %1 is either host IP or already blocked earlier >> %systemdrive%\Qaas\Qaas-%dw%-%mm%-%dd%-%hh%.log
)
This is the blocked IP file: http://pastebin.com/cP4BteDM
Now, trying to block, for example, 10.02.0, I'm receiving in console "10.02.02". I guess because 10.02.0 is "instr" "10.02.02". With this problem in the FINDSTR sentence, I will never be able to ban "10.02.0" for example.
Thank you in advance !!