Can I just ask for a minute WHY you need to do this? Is there any reason why this can't work through an A or CNAME record in your internal DNS records - or is this for running when users are disconnected from your network?
The problem with any logon script or similar is that the user does not have rights to the hosts table by default unless they are local admins, which they generally won't be.
You could run a script as part of a startup script though through group policy if you have that, e.g.
@echo off
set hosts="%systemroot%\system
set newip=192.168.199.10
set newname=server1
REM Check if it is already in there:
find /I "%newip%" < %hosts%
if errorlevel 1 echo %newip% %newname%>>%hosts%
Main Topics
Browse All Topics





by: emiopsPosted on 2009-09-14 at 10:53:44ID: 25327724
If you know a little .vbs you can utilize the Group Policy Logon to execute the .vbs script. With a logon script, every time a user signs onto a computer in your domain the .vbs script will execute. We utilize logon scripting for adding printers and network shares to each user's computer, along with ensuring each system has specific files on their computer.
echnet/scr iptcenter/ resources/ qanda/dec0 4/hey1209. mspx
Here is just one example I found on the net in a 5 second search.
http://www.microsoft.com/t