Re: Deploying a HOSTS file via Group Policy

From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 07/22/04


Date: Thu, 22 Jul 2004 21:24:29 +0200

Mark wrote:

> I would like to know if it is possible to create a GPO that will
> reference a pre-configured HOSTS file? I know it is possible to
> use Software Restriction Policies to restrict .exe from running
> on desktops, but i can't seem to find anywhere that will discuss
> pushing out a HOSTS file. I know that SMS will do this, but i am
> not using SMS on my network. Any information would be appreciated.
Hi

If the users are local admins, you can do it in a logon script, and
if not, you could do it in a computer startup script (with a GPO)
that runs as part of the boot up process (before the user logs in).
It runs under the system context and has admin rights.

To obtain the path to the hosts file on the local computer, this
is how to do it with a VBScript:

'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")
sRegValue = "HKLM\SYSTEM\CurrentControlSet\Services" _
                & "\Tcpip\Parameters\DataBasePath"
sHostsPath = oShell.RegRead(sRegValue)

WScript.Echo "Path to host file: " & sHostsPath
'--------------------8<----------------------

To be able to get the pre-configured hosts file over the network from
the computer startup script, you could put the file(s) on a network
share and grant read access for the AD group "Domain Computers" to the
share.

Alternatively, from the startup script, you could map a drive on
the fly, like this:

'--------------------8<----------------------
sDomainUser = "arp.corp\computer_fix"
sPswd = "something"

Set oNetwork = CreateObject("Wscript.Network")

oNetwork.MapNetworkDrive _
       "Y:", "\\server\netlogon\some folder",, sDomainUser, sPswd
'--------------------8<----------------------

-- 
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx


Relevant Pages

  • Re: Some SBS users cant load javascript in webpage frames
    ... On the Advanced tab of Internet Options - "Display notification about script ... I use the MSVP Hosts file and find that I frequently get errors for "Object ... load up all the frames w/in a webpage. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • RE: Installing a Networked Printer
    ... the printer connections entry for the HKEY_USERS\.DEFAULT ... Putting the script in the user part of a group policy object linked to the ... > A computer startup script can fail if the computer can't access certain user ... so the printer and the server must be fine. ...
    (microsoft.public.windows.server.scripting)
  • Re: IE6 hangs on loading ABCNEWS.COM ESPN.COM HSN.COM DISNEY.COM
    ... I can see the lite version of ESPN just fine" ... Blocking Spyware, Adware, Parasites, Hijackers, Trojans, with a HOSTS file ... >> Some of the script prompts are about "Flash", ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Nameserver failure in scripts FC5
    ... I have a script that calls lynx each hour to check the IP address of my ... hard wire the IP address in the hosts file it will work). ... Yum started to complain that it could not find any mirrors. ...
    (comp.os.linux.networking)
  • Re: Enabling file and print services on multiple pcs.
    ... you could do it in a computer startup script ... PsExec can even automatically copy a file over to the remote computer ...
    (microsoft.public.win2000.general)

Quantcast