I think this is what you are looking for.. [Smile]

code:
BREAK ON CLS

:hostsinstall
If (@inwin = 1)
$windir = READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion","SystemRoot")
$hostsdir = $windir + "\SYSTEM32\DRIVERS\ETC"
$hostsdirfile = $windir + "\SYSTEM32\DRIVERS\ETC\LMHOSTS"
ELSE
$windir = READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","SystemRoot")
$hostsdir = $windir
$hostsdirfile = $windir + "\HOSTS"
ENDIF

;This is setup with IP Address and Alias of the Server
$ipalias = "1.2.3.4"+chr(9)+chr(9)+"installs"
$eol = Chr(13)+Chr(10)
$result = 1
IF exist($hostsdirfile)
$result = open( 1 , $hostsdirfile )
ELSE
IF exist($hostsdirfile)
$result = open( 1 , $hostsdirfile )
ELSE
;BEEP
;You could XCOPY a "pre-canned" HOSTS file from a NETLOGON share on the next line instead of an error message
COPY @ldrive+"HOSTS" $hostsdir
;? "Sorry, the HOSTS file appears to be missing."
;Comment out the next COMMAND line to create the HOSTS file anyway
GOTO OUTPUT1
ENDIF
ENDIF

IF $result = 0
$line = readline( 1 )
WHILE @error = 0
$line = readline( 1 )
;We are going to compare the $line and $IPALIAS
IF $line = $ipalias
;Uncomment out the next line to turn on visual results.
;$EDITRESULT = 'The hosts line you were looking for is already there, no mods were made.'
GOTO OUTPUT
ELSE
;Uncomment out the next line to turn on visual results.
;$EDITRESULT = 'We added the hosts line for you - ' + $IPALIAS
ENDIF
LOOP
$result = close( 1 )
ELSE
;BEEP
;You could XCOPY a "pre-canned" HOSTS file from a NETLOGON share on the next line instead of an error message
COPY @ldrive+"HOSTS" $hostsdir
;? "Sorry, failed to open HOSTS, errorcode : [" + @ERROR + "]"
;Comment out the next COMMAND line to create the HOSTS file anyway
GOTO OUTPUT1
ENDIF

:output
;We need to check for the existence of the $IPALIAS and if it not found add in the line
;Uncomment out the next line to turn on visual results.
;? $EDITRESULT SLEEP 3
;IF $EDITRESULT = 'N'
$result = 2
IF Open(2,$hostsdirfile,5) = 0
$o = WriteLine(2,$ipalias+$eol)
ENDIF
IF close(2) = 0
ENDIF
;Make sure the 1st file is closed
$result = close( 1 )
RETURN

:output1
;Make sure the 1st file is closed
$result = close( 1 )
RETURN

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's