Re: need to modify lmhosts file for all pc's in network
- From: Greg Mohr <GregMohr@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 29 Jul 2005 20:11:02 -0700
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
>
>
>
.
- Follow-Ups:
- Re: need to modify lmhosts file for all pc's in network
- From: David H. Lipman
- Re: need to modify lmhosts file for all pc's in network
- References:
- need to modify lmhosts file for all pc's in network
- From: Greg Mohr
- Re: need to modify lmhosts file for all pc's in network
- From: David H. Lipman
- need to modify lmhosts file for all pc's in network
- Prev by Date: Re: need to modify lmhosts file for all pc's in network
- Next by Date: Re: need to modify lmhosts file for all pc's in network
- Previous by thread: Re: need to modify lmhosts file for all pc's in network
- Next by thread: Re: need to modify lmhosts file for all pc's in network
- Index(es):
Relevant Pages
|