Quantcast
Channel: Group Policy forum
Viewing all articles
Browse latest Browse all 19997

Group Policy Startup Script to Append Hosts File

$
0
0

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


Viewing all articles
Browse latest Browse all 19997

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>