Re: need to modify lmhosts file for all pc's in network



David,

I understand that, but what I need to do is send a script to 5 locations
across 4 states and have a line added to the lmhosts file inserting the new
entry. I have been playing with sample scripts and scriptomatic2, but am
going bonkers trying to figure out the objects.
Please note that the txt extension is only for testing.

Here is what I am trying to use:

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colOSItems = objWMIService.ExecQuery("SELECT * FROM
Win32_OperatingSystem")
For Each objOSItem In colOSItems
WScript.Echo "System Directory: " & objOSItem.SystemDirectory
Next

Dim FileSys
Dim Shell
Dim File

'Create a new lmhosts file in the system32\drivers\etc directory
Set objShell = CreateObject("Shell.Application")
Set objFolder = objOSItem.SystemDirectory
Set objFolderItem = FileSys.CreateTextFile(objOSItem.SystemDirectory &
"\drivers\etc\lmhosts.txt")
File.WriteLine "192.168.9.99 name.domain.com #PRE"
File.Close

'This is only for the testing phase
wScript.Echo "A new file, lmhosts.txt, has been created on your PC."

"David H. Lipman" wrote:

> From: "Greg Mohr" <GregMohr@xxxxxxxxxxxxxxxxxxxxxxxxx>
>
> | I need to be able to find the lmhosts file and then modify it with several
> | lines of information. I am new to scripting, but can see the value in
> | learning this as quickly as possible.
> |
> | The networks have W2K and Win XP machines on it.
> |
> | Any tips would be greatly appreciated.
> |
> | TIA
>
> LMHosts is in; %windir%\system32\drivers\etc
>
> You can either copy a pre-created lmhosts file in this location and then execute;
> nbtstat -R { that's a capital R }
> after you drop the file or you can append to the existing file with the correct information
> you want to add and then execute; nbtstat -R
>
> --
> Dave
> http://www.claymania.com/removal-trojan-adware.html
> http://www.ik-cs.com/got-a-virus.htm
>
>
>
.



Relevant Pages

  • Re: need to modify lmhosts file for all pcs in network
    ... | across 4 states and have a line added to the lmhosts file inserting the new ... | Dim FileSys ... Login Script? ... Another thought is if the workstation is remote, requireing a LMHOSTS entry, then the remote ...
    (microsoft.public.windows.server.scripting)
  • Re: need to modify lmhosts file for all pcs in network
    ... together under a holding company. ... every location and the servers that are there do not "talk" with each other ... I have to email this script to everyone and have them run it on their PCs, ... All I need to do is find the lmhosts file and add one line of information to ...
    (microsoft.public.windows.server.scripting)
  • Re: need to modify lmhosts file for all pcs in network
    ... > | together under a holding company. ... > | every location and the servers that are there do not "talk" with each other ... > Email them the updated LMHOSTS file with a simple copy script that will drop the new LMHOSTS ...
    (microsoft.public.windows.server.scripting)
  • Re: need to modify lmhosts file for all pcs in network
    ... Greg, ... are trying to use File.WriteLine and File.Close, but how is the script ... the servers are too old and don't serve DHCP at the present ... >> Email them the updated LMHOSTS file with a simple copy script that will ...
    (microsoft.public.windows.server.scripting)
  • Re: Getting Error Running Script
    ... Microsoft MVP [Windows XP Shell/User] ... "David Langschied" wrote: ... I am getting an error running a script on Win XP Pro SP2. ... Dim fServer ...
    (microsoft.public.windowsxp.general)