Solved

Updating Hosts file on the local PC using Login Script

Posted on 2014-01-19
9
2,278 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
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 70

Accepted Solution

by:
KCTS earned 167 total points
Comment Utility
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 35

Assisted Solution

by:Mahesh
Mahesh earned 84 total points
Comment Utility
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 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 83 total points
Comment Utility
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
 

Author Comment

by:sglee
Comment Utility
@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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 19

Assisted Solution

by:deroode
deroode earned 166 total points
Comment Utility
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
Comment Utility
@ 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
Comment Utility
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
Comment Utility
@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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

You might have come across a situation when you have Exchange 2013 server in two different sites (Production and DR). After adding the Database copy in ECP console it displays Database copy status unknown for the DR exchange server. Issue is strange…
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now