 | [Other] Adding entries to HOSTS file by batch script? I just want to know how can I add for example the following lines or entries to my HOSTS file using a batch script? And how can I ensure that these new entries will remain somewhere in the bottom and not to scatter all around?
For example, i want to add the following by using a batch script.
127.0.0.1 1.com 127.0.0.1 2.com 127.0.0.1 3.com 127.0.0.1 4.com 127.0.0.1 5.com 127.0.0.1 6.com
Thx in advance. |
|
|
|
 williamray507No More Mr Nice GuyPremium join:2001-10-04 Kernersville, NC 1 edit | Put this in the Batch file and it should work.
@ECHO OFF
TITLE=Update Hosts File
copy C:\Windows\System32\drivers\etc\hosts C:\Windows\System32\drivers\etc\hosts.bck
ECHO. >> C:\Windows\System32\drivers\etc\hosts
ECHO 127.0.0.1 1.com >> C:\Windows\System32\drivers\etc\hosts
ECHO 127.0.0.1 2.com >> C:\Windows\System32\drivers\etc\hosts
ECHO 127.0.0.1 3.com >> C:\Windows\System32\drivers\etc\hosts
ECHO 127.0.0.1 4.com >> C:\Windows\System32\drivers\etc\hosts
ECHO 127.0.0.1 5.com >> C:\Windows\System32\drivers\etc\hosts
ECHO 127.0.0.1 6.com >> C:\Windows\System32\drivers\etc\hosts
EXIT
Added the echo. so that it would add CR.
-- "I think I see the light at the end of the tunnel, Oh wait it's the train" |
|
 LLigetfa join:2006-05-15 Fort Frances, ON kudos:1 | You may want to sent a CR first in case the last line is lacking one. |
|
 ltsnowPremium join:2006-04-08 Valdosta, GA kudos:1 | reply to williamray507 Hey, thanks for this little nugget. |
|