I have written a bat script which will add a line to a hosts file. However I also want to delete any lines which already have the same address. For example:
Add lines 192.168.1.1 wwww.google.com
I want to check if there is already a line with www.google.com and remove it.
Can someone explain how to do this please?
My .bat to append a line. I need to edit it to first delete a line then add this one.
@ECHO off
ECHO. >> %WinDir%\System32\drivers\etc\hosts
FINDSTR /V "217.168.173.1" "%WinDir%\system32\drivers\etc\hosts"
ECHO 123.456.7.1 www.google.com >> %WinDir%\system32\drivers\etc\hosts
EXIT