How do i auto insert a line into a hosts file?

  • Thread starter Thread starter R!K
  • Start date Start date
R

R!K

Need to add an IP address onto 400+ PCs and wondered if I could auto
insert a line into the hosts file with a DOS command?! Have looked for
hours, and so far just coming up with anti-adware help.

your advice would be appreciated!

Thanks
 
In
R!K said:
Need to add an IP address onto 400+ PCs and wondered if I could auto
insert a line into the hosts file with a DOS command?! Have looked for
hours, and so far just coming up with anti-adware help.

your advice would be appreciated!

Thanks

create your hosts file then add a line to the login script to copy over your
copy of it to the PC's as the users log on
 
In



create your hosts file then add a line to the login script to copy over your
copy of it to the PC's as the users log on

Thanks for your help Steve, but as I do not grant access to a DNS
server, each PC currently has different HOST files giving specific
access to the sites they require. so need to know how to add a line to
various hosts! Sorry should have said before!
 
R!K said:
Need to add an IP address onto 400+ PCs and wondered if I could auto
insert a line into the hosts file with a DOS command?! Have looked for
hours, and so far just coming up with anti-adware help.

your advice would be appreciated!

Thanks

As an alternative to Steve's suggestion you could
add this very long line to your logon script:

type "c:\winnt\system32\drivers\etc\hosts" | find /i "MyNewHost" || echo
192.168.55.123 MyNewHost >> "c:\winnt\system32\drivers\etc\hosts"

where "MyNewHost" is the name of your new host
and 192.168.55.123 is its address.
 
As an alternative to Steve's suggestion you could
add this very long line to your logon script:

type "c:\winnt\system32\drivers\etc\hosts" | find /i "MyNewHost" || echo
192.168.55.123 MyNewHost >> "c:\winnt\system32\drivers\etc\hosts"

where "MyNewHost" is the name of your new host
and 192.168.55.123 is its address.

Hi Pegasus, tried your suggestion and unfortunately didn't work, have
typed the line directly to command prompt, and get the following
message, so maybe I have messed up the context,,

C:\> "c:\winnt\system32\drivers\etc\hosts" | find /i "MyNewHost" ||
echo
"c:\winnt\system32\drivers\etc\hosts" is not recognised as an
internal or external command, operable program or batch file.
C:\>10.10.0.100 MyNewHost >> "c:\winnt\system32\drivers\etc\hosts"

any suggestions?

R!K
 
R!K said:
Hi Pegasus, tried your suggestion and unfortunately didn't work, have
typed the line directly to command prompt, and get the following
message, so maybe I have messed up the context,,

C:\> "c:\winnt\system32\drivers\etc\hosts" | find /i "MyNewHost" ||
echo
"c:\winnt\system32\drivers\etc\hosts" is not recognised as an
internal or external command, operable program or batch file.
C:\>10.10.0.100 MyNewHost >> "c:\winnt\system32\drivers\etc\hosts"

any suggestions?

R!K

My line started with the word "type". Yours didn't.
 
My line started with the word "type". Yours didn't.- Hide quoted text -

- Show quoted text -

thought that was a prompt. dunce hat for me. will try again tomorrow.
thanks again for your help.
 
Back
Top