Update the hosts file with a batch file.

September 20, 2011 at 11:02:40
Specs: Windows XP
I want to update the whole content of hosts file with a text file (data1.txt) by running a batch (.bat) file. Please help.

Actually my hosts file is pretty simple with just one line:
1xx.x.x.x localhost

I have two conditions for which I need to add two different lines of the form shown below, right after the above line.
10.xxx.xx.x1 server_1_name #comment_1
(OR) - [this is condition dependent]
10.xxx.xx.x2 server_2_name #comment_2

I will create two batch files for server_1 and server_2 and two text files with the contents of the hosts file for the two conditions(data1.txt and data2.txt); So when I run the batch file for server_1, only that entry gets entered into the hosts file; and the same for server_2.

For the above condition, please help with the script for the bacth file.

Also, please let me know if there is a better way to do it, instead of creating the data files. I might have to do checking for existing text - where I came into problems with checking for spaces.

See More: Update the hosts file with a batch file.

Report •

September 21, 2011 at 07:31:02
Use Copy command
copy doc1.txt+doc2.txt doc3.txt
By this you can copy contenst of doc1.txt and doc2.txt o dox3.txt

Hope this resolves in an easy manner

Floppy Drive to USB
Floppy Disk to USB
Floppy Disc to USB

Report •
Related Solutions

Ask Question