I'm trying to add an entry to the Hosts file on my Windows clients. We don't have an internet URL for our DAC IP address so we have to fake one in the Host file.
I found a simple script to append it, but it keeps adding the new entry on the same line as the last REM'd sample line in the host file.
How can do this so it reliably creates the new entry on a new line without duplicates?
@echo off SET NEWLINE=^& echo. FIND /C /I "da.contoso.com" %WINDIR%\system32\drivers\etc\hosts IF %ERRORLEVEL% NEQ 0 ECHO %NEWLINE%^62.116.159.4 da.contoso.com>>%WINDIR%\System32\drivers\etc\hosts
There's no place like 127.0.0.1