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" <figo@gmail.com> wrote:

> 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

--
d-d
 
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 ?


"Detlev Dreyer" <detdreyer@flashmail.com> wrote in message
news:1d69ee79b0e49de11f6dbccc4cc48a96@d-d.mvps.org...
> "Figo" <figo@gmail.com> wrote:
>
>> 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
>
> --
> d-d
 
Figo wrote:
> 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 ?
>
>
> "Detlev Dreyer" <detdreyer@flashmail.com> wrote in message
> news:1d69ee79b0e49de11f6dbccc4cc48a96@d-d.mvps.org...
>> "Figo" <figo@gmail.com> wrote:
>>
>>> 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


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.

--
Joe =o)
 
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


"Elmo" <elmogeek@iglou.invalid> wrote in message
news:uq86S7xQIHA.2208@TK2MSFTNGP06.phx.gbl...
> Figo wrote:
>> 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 ?
>>
>>
>> "Detlev Dreyer" <detdreyer@flashmail.com> wrote in message
>> news:1d69ee79b0e49de11f6dbccc4cc48a96@d-d.mvps.org...
>>> "Figo" <figo@gmail.com> wrote:
>>>
>>>> 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

>
> 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.
>
> --
> Joe =o)
 
"Figo" <123@gmail.com> wrote:

> 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.

--
d-d
 
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


"Detlev Dreyer" <detdreyer@flashmail.com> wrote in message
news:0b3485bbadb400187dd918ec862037e9@d-d.mvps.org...
> "Figo" <123@gmail.com> wrote:
>
>> 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.
>
> --
> d-d
 
On 20 Dec, 09:35, "Figo" <f...@gmail.com> wrote:
> 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" <123@gmail.com> wrote:

> 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.

--
d-d
 
thanks again...


<w.ian.stuart@googlemail.com> wrote in message
news:e77e29b4-1faa-49d5-8f9a-0557a001c649@d21g2000prf.googlegroups.com...
> On 20 Dec, 09:35, "Figo" <f...@gmail.com> wrote:
>> 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.
 
On 20 Dec, 16:47, "Detlev Dreyer" <detdre...@flashmail.com> wrote:
> "Figo" <1...@gmail.com> wrote:
> > 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.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.
>
> --
> d-d



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.
 
"w.ian.stuart@googlemail.com" wrote:

> On 20 Dec, 16:47, "Detlev Dreyer" <detdre...@flashmail.com> wrote:
>> "Figo" <1...@gmail.com> wrote:
>>> 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.uk/vbscript/vbscript_file_opentextf...
>>
>> In case of further questions (not a Windows issue) repost to
>> news://msnews.microsoft.com/microsoft.public.scripting.wsh
>>

>
> 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.

--
d-d
 
Back
Top