How can i add text to a host file through cmd?

shrshr429

Solid State Member
Messages
19
I just want to add (example):


127.0.0.1 localhost
127.0.0.1 google.com

to my host file - windows\sytem32\drivers\etc\hosts

through cmd, how can i do this?
 
Code:
echo >> 127.0.0.1 google.com C:\windows\sytem32\drivers\etc\hosts

That might work for you. I don't remember if the 'hosts' file is a text file or something else in Windows, though. Best thing to do is create a copy of your hosts file and test it on that first.

Out of interest, is there a reason you want to do this?

Edit: Whatever you do, don't miss out one of the less-than signs. If you were to do the following:

Code:
echo > 127.0.0.1 google.com C:\windows\sytem32\drivers\etc\hosts

It would add 127.0.0.1 google.com to the file, but would delete everything else in there first (assuming that it works at all).
 
to Add this:

# Start of entries inserted by Spybot - Search & Destroy
127.0.0.1 www.007guard.com
127.0.0.1 007guard.com
127.0.0.1 008i.com
127.0.0.1 www.008k.com
127.0.0.1 008k.com
127.0.0.1 www.00hq.com
127.0.0.1 00hq.com
127.0.0.1 010402.com
127.0.0.1 www.032439.com
127.0.0.1 032439.com
127.0.0.1 www.0scan.com
127.0.0.1 0scan.com
127.0.0.1 www.1000gratisproben.com
127.0.0.1 1000gratisproben.com
127.0.0.1 www.1001namen.com
127.0.0.1 1001namen.com
127.0.0.1 100888290cs.com
127.0.0.1 www.100888290cs.com

..........

Prevent spyware on my comp.
 
Somehow I thought it wouldn't. :/

I'll keep looking in to it for you, but I don't have a Windows machine to test it on, so I can't say whether or not something would work. It might end up being easier if you altered the file using a text editor of some kind. Or using a script (though that script might have to first rename the file with the .txt extension, then write to it, then remove .txt) of some kind.
 
Back
Top Bottom