Solved

Updating Hosts file on the local PC using Login Script

Posted on 2014-01-19
9
2,486 Views
Last Modified: 2014-01-29
Hi,
 
 I have hosts file that changes from time to time due to the fact that we host several websites internally on our web server with IP address 192.168.1.4. When the users open the browser and type in ABC.com, NBC.com, CBS.com, I want the browser to go directly to my web server instead of going to the Internet to find those websites (because they are running within the network). But this requires updating hosts file (located in
C:\WINDOWS\system32\drivers\etc ) on each workstation PC  to reflect the new website addition or what have you.

192.168.1.4     ABC.com
192.168.1.4     NBC.com
192.168.1.4     CBS.com

xcopy \\DC1\share\hosts C:\WINDOWS\system32\drivers\etc /c /y

Is there a way to incorporate the XCOPY command above (that copies newest hosts file on the network Share folder and replace the hosts file on workstation PC) automatically as a part of login process?

Thanks.
0
Comment
Question by:sglee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 70

Accepted Solution

by:
KCTS earned 167 total points
ID: 39792392
Why use the hosts file - use your DNS server and make the entries there - only one place to make the changes when needed and no need to do anything to the clients.
0
 
LVL 37

Assisted Solution

by:Mahesh
Mahesh earned 84 total points
ID: 39792414
yes, that's absolutely right.

However You can use GP preferences to achieve that
http://serverfault.com/questions/298138/deploy-hosts-file-among-machines-connected-to-a-domain

GP preferences are compatible on Win Vista and above natively

You can use it on Win XP once you install below patch on XP
http://www.microsoft.com/en-in/download/details.aspx?id=3628

Mahesh
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 83 total points
ID: 39792486
And your 'hosts' file is often restricted by your anti-virus program so that it can't be easily changed.  Changes to the 'hosts' file used to be a favorite attack method to redirect browsers from some place like Google to a malware site.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sglee
ID: 39792554
@kcts
DNS is where I wanted to do too. However I was not able to get needed help on this board when I posted the question.
0
 
LVL 19

Assisted Solution

by:deroode
deroode earned 166 total points
ID: 39793808
You would place the xcopy command in a Startup script, as it runs in the local system context, and thus has the rights to update this file. The logon script runs in the local user context, and has no rights to update the hosts file.
0
 

Author Comment

by:sglee
ID: 39804340
@ deroode

I have this xcopy command that I like to insert into user login script file.
--------------------------------
xcopy \\DC1\share\hosts C:\WINDOWS\system32\drivers\etc /c /y
--------------------------------


Here is a sample Login Script "Users.bat" in \\DC1\netlogon folder on the file server.
--------------------------------
net time \\DC1 /set /yes
net use F: \\DC1\%username%
net use G: \\DC1\Share
--------------------------------

Can you show me how to integrate my XCOPY command into the user login script so that hosts file is copied to local PC every time users log in to the network?
0
 
LVL 70

Assisted Solution

by:KCTS
KCTS earned 167 total points
ID: 39804515
It does not make sense to change the host file in this way

Simply go to the DNS console, right click and add/edit an  A record for the desired IPs
http://www.youtube.com/watch?v=WYj7KSIn2Xo
0
 

Author Comment

by:sglee
ID: 39804544
@KCTS
Thanks for the link. I will try that tonight and get back to you.
0
 
LVL 19

Assisted Solution

by:deroode
deroode earned 166 total points
ID: 39805912
As stated before: Do not add the Xcopy command to the user login script, but to the computer startup script; Users don't have the right to update the Hosts file;

Create or edit a policy wich is associated to your workstations, goto Computer configuration - Windows Settings - Scripts (Startup/Shutdown); Create a startup script (e.g. \\domain\netlogon\startup.cmd) and put your Xcopy command in there.
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
A hard and fast method for reducing Active Directory Administrators members.
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question