B
bosiydid
Does anyone know how I can insert a line into the 'hosts'
using my logon script that runs from the server? Thank
you.
using my logon script that runs from the server? Thank
you.
bosiydid said:Does anyone know how I can insert a line into the 'hosts'
using my logon script that runs from the server? Thank
you.
'// Add server(s) to client host file
Option Explicit
Dim sFile, sHost, sSysDir, oHost
Dim oFSO, sCheck
Const WindowsFolder = 0
Const ForReading = 1
Const ForAppending = 8
sFile = "\system32\drivers\etc\hosts"
Set oFSO = CreateObject("Scripting.FileSystemObject")
'// Get the %system% folder
Set sSysDir = oFSO.GetSpecialFolder(WindowsFolder)
sHost = sSysDir & sFile
Set oHost = oFSO.OpenTextFile(sHost, ForReading, False)
sCheck = oHost.readall
If instr(sCheck, "server.whatever.com") = 0 Then
oHost.close
wscript.sleep 500
Set oHost = oFSO.OpenTextFile(sHost, ForAppending, False)
oHost.writeline vbcrlf
oHost.writeline "x.x.x.x" & vbTab & "server.whatever.com"
End If
oHost.close
OK,
I took your code, modified the script to look like this....
'// 2003 Michael Holzemer
If I do this manually it works so I know that the IP and
the server name both work. Any more help you can provide
would be GREATLY appreciated.