Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Adding a sentence to host file.

Posted on 2006-11-10
8
Medium Priority
?
343 Views
Last Modified: 2010-04-16
Hello All, i wish to know how to add a sentence to host file using the batch file.

echo 127.0.0.1 localhost >> "%systemroot%\system32\drivers\etc\hosts"

But everytime i double click this batch file. Instead of going to the next sentence of the host file, it will just add next to the last line of the host file. example:-

xx.xx.xx.xx   www.yahoo.com.sg After i double click the host file above it will become:-

xx.xx.xx.xx   www.yahoo.com.sg 127.0.0.1 localhost

But i want the 127.0.0.1 localhost to be at the next sentence. Isst possible?

Please advice me.

0
Comment
Question by:YeoBoonWah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
8 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 172 total points
ID: 17912889
echo >>  "%systemroot%\system32\drivers\etc\hosts"
echo 127.0.0.1 localhost >> "%systemroot%\system32\drivers\etc\hosts"
0
 
LVL 19

Assisted Solution

by:Albert Van Halen
Albert Van Halen earned 164 total points
ID: 17912900
You can use \n characters

IE echo "\n127.0.0.1 localhost" >> "%systemroot%\system32\drivers\etc\hosts"
0
 
LVL 84

Expert Comment

by:ozo
ID: 17913009
if this is dos, you may need
echo. >>  "%systemroot%\system32\drivers\etc\hosts"
0
 
LVL 3

Assisted Solution

by:JRockSolid
JRockSolid earned 164 total points
ID: 17921353
Make sure your cursor i on an empty line in your host file then save it  EXAMPLE

Line#
1  127.0.0.1 localhost
2  127.0.0.1 localhost
3  127.0.0.1 localhost
4  127.0.0.1 localhost
5  127.0.0.1 localhost
6  |<<<<Cursor here and save
------------------------------------------------
now try it
0
 
LVL 3

Expert Comment

by:JRockSolid
ID: 17958477
Any Luck YEO?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question