|
|
|
| 4 February 2003 | HostsInstall() |
| Author | Kent Dyer |
| Action | Checks for an IP Address and alias name. If needed, it will update. |
| Syntax | HostsInstall () |
| Parameters | |
| Remarks | user would need Power User or Administrative Access to modify the HOSTS file. |
| Returns | Nothing |
| Dependencies | None. |
| Examples | $rc=HostsInstall() |
| Source |
FUNCTION HostsInstall ()
$hostsdir='%windir%\system32\drivers\etc'
$hostsdirfile=$hostsdir+'\hosts' ;This is setup with IP Address and Alias of the Server
$ipalias='1.2.3.4'+Chr(9)+Chr(9)+'installs'
IF Exist($hostsdirfile)
$=Open(1,$hostsdirfile)
$line=ReadLine(1)
WHILE (@error=0) AND ($ip <> 'found')
IF ($line = $ipalias)
$ip='found'
ENDIF
$line=ReadLine(1)
LOOP
$=Close(1)
IF ($ip <> 'found')
$=Open(2,$hostsdirfile,5)
$=WriteLine(2,$ipalias+@crlf)
$=Close(2)
ENDIF
ELSE
;--HOSTS is not found, copy one over
COPY @ldrive+'HOSTS' $hostsdir
ENDIF
ENDFUNCTION ; - HostsInstall -
|
|
|
|