• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 800
  • Last Modified:

Host File

Is it possible to edit the windows host file through group policy?
4 Solutions
Emmanuel AdebayoGlobal Windows Infrastructure Engineer - ConsultantCommented:
There is no direct way you can you Group Policy to edit Windows host files. Why are you doing this? Is DNS not abel to accomplish the purpose.

There is a VB script that you use, though I have not tested it, please test this in your development enviroment first.


QlemoBatchelor and DeveloperCommented:
Doing it thru scripting should not be an issue. VBS or PowerShell will both come handy here. Even conventional cmd batch scripting should work, depending on the demands.
binumhaneefAuthor Commented:
In our branch we have static ip address so we need to change the host by group policy if possible
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

QlemoBatchelor and DeveloperCommented:
DNs works very well with static IP addresses, and makes life much easier as it is kept up-to-date automatically.
Sanjay SantokiCommented:

There isn't any way to do it through Group policy but logically here is the workaround if you are going to replace same host file on each machine;

Create a HOST file and save it on network location -> Create a Batch file which includes copy command to copy HOST file from network locations to the C:\Windows\System32\Drivers\Etc
Put it under startup through group policy

Sanjay Santoki
Is it possible to edit the windows host file through group policy?

Yes you can, quite easily.

First place the host file on a network share that the required users have access to.

Under Computer Configuration\Preferences\Windows Settings\Files, add a new file item.
For Action, select "Replace".
For Source file(s), enter the full UNC path of your shared host file (for example, "\\SERVER1\Share\hosts".
For Destination File, enter "C:\Windows\System32\Drivers\etc\hosts".

Run gpupdate /force on the target machines (or just reboot) and the host file should update automatically.

Having said that, I agree with the other posters that setting up a DNS server would be a much better solution in this case.
David Johnson, CD, MVPOwnerCommented:
Fix your dns issues so you don't need to use the hosts file.. what you are doing is recreating 1980's technology.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now