Showing posts with label Host file. Show all posts
Showing posts with label Host file. Show all posts

Thursday, March 18, 2010

Batch to add/remove IP address in hosts file

Add IP address

IF NOT EXIST C:\WINDOWS\system32\drivers\etc\hosts_o Copy C:\WINDOWS\system32\drivers\etc\hosts C:\WINDOWS\system32\drivers\etc\hosts_o

Copy C:\WINDOWS\system32\drivers\etc\hosts C:\WINDOWS\system32\drivers\etc\hosts_bk /y

echo 1.5.3.8    x.xxx.com >> C:\WINDOWS\system32\drivers\etc\hosts

 

Remove IP address

Copy C:\WINDOWS\system32\drivers\etc\hosts C:\WINDOWS\system32\drivers\etc\hosts_bk2 /y

Copy C:\WINDOWS\system32\drivers\etc\hosts_o C:\WINDOWS\system32\drivers\etc\hosts /y

Print Friendly and PDF
Share/Bookmark

Monday, November 23, 2009

GPO + bat file to edit host files

It is create your host file and deploy it with a startup script which doesn't require that the user has admin rights since it runs on machine account.
Put your host file on a share and create a batch file with this line:

type \\server\sharename\hosts >>%systemroot%\system32\drivers\etc\hosts

Then go in your group policies:
Computer configuration / Windows settings / Scripts / Startup
and use your script. At next startup everyone will have new hosts file.

(Reference: http://www.experts-exchange.com/Software/Server_Software/Email_Servers/Exchange/Q_23790188.html)

Print Friendly and PDF
Share/Bookmark

Wednesday, November 11, 2009

Add record to hosts file by command

echo 127.0.0.1 abc.com >> C:\WINDOWS\system32\drivers\etc\hosts

The 127.0.0.1 abc.com will append to the lastest line of the host file. Print Friendly and PDF
Share/Bookmark