Batch file to add line to hosts file

i want to add a line to the hosts file.  i'm used to unix programming, and not batch files...
how do i add a line to a file using a batch file?
LVL 44
zephyr_hex (Megan)DeveloperAsked:
Who is Participating?
 
brettmjohnsonCommented:
echo 192.168.1.10   newhostname >> C:\WINNT\system32\drivers\etc\hosts

Note the location of the hosts file may vary depending upon your version of windows.

0
 
wnrossCommented:
This is a line in a windows box I gather?

echo "127.0.0.1  foo.bar.com" >> c:\winnt\system32\drivers\etc\hosts

Cheers
-Bill
0
 
brettmjohnsonCommented:
wnross,
Be aware that he windows version of echo is stupid enough to copy the quote characters to the output stream, so you would end up with the quotes in the hosts file.
0
 
wnrossCommented:
Heh, fair enough

Cheers
-Bill
0
 
zephyr_hex (Megan)DeveloperAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.