edit XP Host Table

  • Thread starter Thread starter Figo
  • Start date Start date
F

Figo

Hi All, I would like to add entrys to Windows XP Host Table using dos
command line, which command can I use and how ?

Thanks a lot
 
Figo said:
Hi All, I would like to add entrys to Windows XP Host Table using dos
command line, which command can I use and how ?

Type at the command prompt:

CD %SystemRoot%\System32\drivers\etc
edit hosts
 
but if I want to use a command to auto add "10.190.10.90 for
homepage.com.hk" in the host table and save, instead of use EDIT in command,
then manually type these words and same save the file, how can I do it ?
 
Figo said:
but if I want to use a command to auto add "10.190.10.90 for
homepage.com.hk" in the host table and save, instead of use EDIT in command,
then manually type these words and same save the file, how can I do it ?

Create a shortcut to:

Notepad.exe %SystemRoot%\System32\drivers\etc\hosts

Name it "Edit Hosts" or another appropriate name. Double-click the
shortcut when you want to add to it. That's got to be as quick as
entering the data into a batch file, or elsewhere, I suspect.

But, I guess you could create a batch file that prompts for the entry,
then appends it.. I can't tell you how it would be done though.
 
thanks for ur reply,

in fact, I would like to create a batch file to auto add some default entrys
to the Host Table ( when I run the batch ), can I do it ? thanks again
 
Figo said:
but if I want to use a command to auto add "10.190.10.90 for homepage.com.hk"
in the host table and save, instead of use EDIT in command, then manually
type these words and same save the file, how can I do it ?

Why do you want to waste your time at the command prompt anyway.
In addition to Elmo's reply: Start > Run: CMD > assoc .=txtfile

Now you can double-click the "Hosts" file in order to edit with Notepad.
 
it is because I have about 20 PCs' Host Table need to edit, so it would be
more easy and quickly if there has a batch for auto apply the edit
 
Hi All, I would like to add entrys to Windows XP Host Table using dos
command line, which command can I use and how ?

Thanks a lot

echo nn.nn.nn.nn hostname >> c:\windows\system32\drivers\etc\hosts

build up a batch file using the syntax above where each line
represents the entry you want to add to hosts.
 
Figo said:
it is because I have about 20 PCs' Host Table need to edit, so it would
be more easy and quickly if there has a batch for auto apply the edit

Still not clear why you stick with the command line since any WSH script
will do that. Here's an example that you may want to modify accordingly:
http://www.computerperformance.co.u...#Summary_of_How_to_Append_Data_to_a_Text_File

In case of further questions (not a Windows issue) repost to
news://msnews.microsoft.com/microsoft.public.scripting.wsh

Good luck.
 
thanks again...


echo nn.nn.nn.nn hostname >> c:\windows\system32\drivers\etc\hosts

build up a batch file using the syntax above where each line
represents the entry you want to add to hosts.
 
Still not clear why you stick with the command line since any WSH script
will do that. Here's an example that you may want to modify accordingly:http://www.computerperformance.co.uk/vbscript/vbscript_file_opentextf...

In case of further questions (not a Windows issue) repost to
news://msnews.microsoft.com/microsoft.public.scripting.wsh

Good luck.


Why would he want to learn the basics of a scripting language, that is
presumably completely alien to him, to do something that can easily be
done with one legacy shell command and output redirection?

The script you pointed him to is going to make no sense to him and
only adds one line to a file anyway. How long do you think it would
take him to modify it to do what he wants, including debugging and
testing, so that he could confidently run it on his production
machines?

WSH scripting has it's place but in this case it is very much a
sledgehammer being used to crack a nut.

KISS.
 
Why would he want to learn the basics of a scripting language, that is
presumably completely alien to him, to do something that can easily be
done with one legacy shell command and output redirection?

Because it's more flexible. Your simple shell command fails when the
%SystemRoot% directory is named "WinNT" (example) rather than "Windows"
or when located on a drive other than the C: drive. In addition, it's
up to the OP which way to go and your opion is of little interest to me.
 
Because it's more flexible. Your simple shell command fails when the
%SystemRoot% directory is named "WinNT" (example) rather than "Windows"
or when located on a drive other than the C: drive. In addition, it's
up to the OP which way to go and your opion is of little interest to me.

What can I say? Check your high hotse, from here it looks lame. Let me
put it another way. You're a sanctimonious, ignorant ****-wit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top