New
#11
I found this
from hereCode:@echo off TITLE Modifying your HOSTS file COLOR 85 ECHO. :LOOP SET Choice= SET /P Choice="Do you want to modify HOSTS file ? (Y/N)" IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1% ECHO. IF /I '%Choice%'=='Y' GOTO ACCEPTED IF /I '%Choice%'=='N' GOTO REJECTED ECHO Please type Y (for Yes) or N (for No) to proceed! ECHO. GOTO Loop :REJECTED ECHO Your HOSTS file was left unchanged >> %systemroot%\Temp\yourinstall.log ECHO Finished. GOTO END :ACCEPTED ECHO Carrying out requested modifications to your HOSTS file echo 127.0.0.1 local host >> %WinDir%\system32\drivers\etc\hosts ECHO Finished. GOTO END :END ECHO. EXIT
and this:
from hereCode:Const ForReading = 1, ForWriting = 2, ForAppending = 8, ReadOnly = 1 Set fso = CreateObject("Scripting.FileSystemObject") Set WshShell=CreateObject("WScript.Shell") WinDir =WshShell.ExpandEnvironmentStrings("%WinDir%") HostsFile = WinDir & "\System32\Drivers\etc\Hosts" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(HostsFile, ForReading) Do Until objFile.AtEndOfStream If InStr (objFile.ReadLine, "10.10.10.105") <> 0 Then WScript.Quit End If i = i + 1 Loop objFile.Close Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.GetFile(HostsFile) If objFile.Attributes AND ReadOnly Then objFile.Attributes = objFile.Attributes XOR ReadOnly End If Set filetxt = fso.OpenTextFile(HostsFile, ForAppending, True) filetxt.WriteLine(vbNewLine & "10.10.10.105 intranet.corp www.intranet.corp intranet www.intranet") filetxt.Close WScript.quit
I will tray them all an see if they did what i want>>