• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 502
  • Last Modified:

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?
0
zephyr_hex (Megan)
Asked:
zephyr_hex (Megan)
  • 2
  • 2
2 Solutions
 
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:
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
 
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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now