Wednesday, January 19, 2011

Updating the HOSTS file in Windows Vista requires special instructions





Due to the restrictions imposed by UAC (Users Access Control) users are prohibited from running any batch files, so the included installer "mvps.bat" does not work unless you turn off or modify UAC (not recommended).
However I have come up with a fairly simple solution ... using the power of SendTo.
[or]
You can Update the HOSTS file via "Elevated" Command Prompt
[or]
You can use one of the Related Utilities specifically designed for this purpose ...
[or]
You can right-click on the included "mvps.bat" and select "Run as Administrator" ... more info here

Updating the HOSTS file via the SendTo method 
The first step is to create a new shortcut in your SendTo folder. Open Windows Explorer to:
\Users\\AppData\Roaming\Microsoft\Windows\SendTo
Note: where "" is your login name
[or]
Start | Run (type) shell:sendto (click Ok)
Next: Right-click in the right pane and select: New > shortcut [screenshot]
In the next dialog box click Browse and navigate to: Windows\System32\drivers\etc
Click Ok and in the next dialog box name the shortcut (example) Update Hosts
In the future when you wish to update the HOSTS file, download the "hosts.zip", extract the included files and right-click on the included updated HOSTS file and select: SendTo > Update Hosts
Note: UAC will prompt for permission for this action, click Ok and proceed ...
Next you will see the below prompt, click Continue and proceed.
Finally you will see a prompt to Copy and Replace the existing file, click Copy and Replace.
Note: this will overwrite (delete) the existing file, so if you have any custom entries in the file I would suggest copying these prior to updating the file. Then open the HOSTS file and paste your custom entries. Alternately you can use the below method that does create a backup of your HOSTS file.
Editors Note: I know this is not a perfect solution, but given the restrictions of the new Windows version it is a workable solution until something is found that offers a better method.
Updating the HOSTS file via "Elevated" Command Prompt
You can add a right-click Folder menu option "Open Command Window Here (Administrator)",
Download cmd-admin.reg then right-click and select: Merge (Ok the prompt) ... no need to reboot.
Next extract the "hosts.zip"
Right-click on the newly created "hosts" folder
Select the option:
Open Command Window Here (Administrator)

Next: (type) mvps.bat (press Enter)
You should see the updated message ...
Thanks to Ramesh Srinivasan, Microsoft MVP
for the suggestion
Modify Users Access Control (Administrators only)

Control Panel > Administrative Tools
Select: Local Security Policy (when prompted, click Continue)

In the left pane, expand Local Policies and click Security Options.
In the right pane, scroll down to User Account Control:
Double-click on: "Behavior Of The Elevation Prompt For Administrators In Admin Approval Mode"

In the drop-down box on the Local Security Settings tab
Select Elevate Without Prompting, Click Apply/OK.
Run as Administrator
Once you unzip (extract) the included files in the "hosts.zip" ... right-click on "mvps.bat" and select: Run as Administrator ...

Next: double-click on "mvps.bat" and let the file back-up your existing and then update your HOSTS file ...
Thanks to Thomas H. for providing help on this method ...

Note: do NOT run Windows Vista/7 with UAC turned off as this also turns off the "Protected Mode" in Internet Explorer.
 Related Utilities
 By modifying the UAC I was able to get HostsMan to work and update the HOSTS file in Vista.
 You can also use HostsXpert to update the HOSTS file in Vista ...
In the event you need to edit the HOSTS file > click here

Labels