Computer Hope

Software => Computer software => Topic started by: shrshr429 on July 03, 2009, 06:47:02 PM

Title: How can i add text to a host file through cmd?
Post by: shrshr429 on July 03, 2009, 06:47:02 PM
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?
Title: Re: How can i add text to a host file through cmd?
Post by: patio on July 03, 2009, 07:56:36 PM
Why thru .cmd  ? ?
Open it in Notepad and add the revisions.
Title: Re: How can i add text to a host file through cmd?
Post by: fat_basterd21 on July 03, 2009, 08:48:12 PM
take a look here
http://technet.microsoft.com/en-us/library/bb490982.aspx

>> is the append command so the output will always be written to the end of the file rather than overwriting. Just using > will overwrite the file each time.

syntax is "(command) >> windows\sytem32\drivers\etc\hosts.txt"

Or
"echo 127.0.0.1 localhost >> windows\sytem32\drivers\etc\hosts.txt"
"echo 127.0.0.1 google.com >> windows\sytem32\drivers\etc\hosts.txt"
Title: Re: How can i add text to a host file through cmd?
Post by: Broni on July 03, 2009, 09:18:57 PM
Quote
Why thru .cmd  ? ?
Open it in Notepad and add the revisions.
Title: Re: How can i add text to a host file through cmd?
Post by: shrshr429 on July 03, 2009, 10:40:10 PM
I want to make it into a batch file and autorun on a cd, its going to block known spyware websites.
Title: Re: How can i add text to a host file through cmd?
Post by: Broni on July 03, 2009, 10:43:18 PM
Honestly, I have no idea what you're trying to do. Why on CD? Hosts file must be located in certain folder, not on CD.
Title: Re: How can i add text to a host file through cmd?
Post by: shrshr429 on July 03, 2009, 10:59:34 PM
Make a batch file that adds


# 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

to the host file located in Windows\system32\drivers\etc\host

make that autorun on a cd.
Title: Re: How can i add text to a host file through cmd?
Post by: Broni on July 03, 2009, 11:09:29 PM
Why does it have to run from some CD, not to go straight to Windows\system32\drivers\etc\?
Title: Re: How can i add text to a host file through cmd?
Post by: fat_basterd21 on July 03, 2009, 11:59:44 PM
Or why not make a .txt file and just save/copy it from a disk?
Title: Re: How can i add text to a host file through cmd?
Post by: shrshr429 on July 04, 2009, 12:18:26 AM
ok then lets look at this differently, if i had a file (hosts) on the cd, how can i replace that tifle with the host file on the computer through cmd. The reason i want to do it through cmd is so i can make a batch file so it can autorun right off the cd.
Title: Re: How can i add text to a host file through cmd?
Post by: soybean on July 04, 2009, 07:24:23 AM
ok then lets look at this differently, if i had a file (hosts) on the cd, how can i replace that tifle with the host file on the computer through cmd. The reason i want to do it through cmd is so i can make a batch file so it can autorun right off the cd.
Your obsession with this technique seems quite odd.  Is this just for your computer, or do you intend this CD to be used for many computers? 
Title: Re: How can i add text to a host file through cmd?
Post by: shrshr429 on July 04, 2009, 02:57:38 PM
Other computers.
Title: Re: How can i add text to a host file through cmd?
Post by: shrshr429 on July 04, 2009, 05:27:24 PM
Lets change the question since this is confusing. I know how to delete a file through cmd, so if i delete the host file through cmd, what would be the script to move a file from a cd to the host file's location.
Title: Re: How can i add text to a host file through cmd?
Post by: fat_basterd21 on July 04, 2009, 09:14:12 PM
copy