Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch file to update HOSTS file 1

Status
Not open for further replies.

jaxtell

Programmer
Sep 11, 2007
349
US
Does anyone know how to write a .bat file to add a line to the HOSTS file? I'm looking for an easy way to fix a VPN DNS issue, and I think adding a line to HOSTS is the best/easiest way. Is there another place I should be asking this question? Thanks.

-----------------------------------------
I cannot be bought. Find leasing information at
 
Very quick and dirty.

@echo off
find "vpn" %windir%\system32\drivers\etc\hosts > NUL
IF ERRORLEVEL 1 GOTO UPDATE
GOTO END

:UPDATE
echo 192.168.0.1 vpn >> %windir%\system32\drivers\etc\hosts

:END


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top