How to edit the hosts file in Windows Vista.
Introduction
I develop and manage my websites and need to edit my hosts file when I’m at certain locations to bypass DNS settings when testing new sites.
It took me a little while and a little research but I figured out how to edit the hosts file in Vista.
Edit the Hosts File
Non-frequent Edit
- Open Notepad with Administrative privileges by clicking Start, All Programs, Accessories, and then right-click Notepad and select to open as Administrator.
- Now that Notepad is open with Administrative privileges browse to (C:\Windows\System32\drivers\etc) in Notepad and open the hosts file.
Now you can edit and save the hosts file.
Frequent Editing
I sometimes frequently edit my hosts file and like a shortcut on my desktop for easy editing. Here’s how to create a shortcut on your desktop and lets you quickly and easily open your hosts file with Notepad and edit it.
- Send a shortcut to Notepad to your desktop by right-clicking Notepad in the start menu and selecting send to desktop.
- Right-click the shortcut to Notepad on your desktop and select properties.
- Click the advanced button near the bottom of the shortcut tab and check off run as administrator. Click OK in the advanced properties window.
- Replace %SystemRoot%\system32\notepad.exe with %SystemRoot%\system32\notepad.exe C:\Windows\System32\drivers\etc\hosts in the target box. Click OK in the properties window to save the changes.
Now all you have to do is open that shortcut to open your hosts file with Notepad with administrative privileges.
Thanks to the first few commenters on this guide for pointing this out to me.

By Munir on January 24th, 2007 at 10:22 am #
You also could just open your editor with administrator privileges (right-klick, “Run as administrator”).
By Thava on January 24th, 2007 at 2:33 pm #
Thanks for this information.
It was useful for me.
/ Thava
By ssuede8 on February 2nd, 2007 at 12:36 pm #
Thanks!
By Jim on February 4th, 2007 at 5:08 pm #
Hey guys, heres a better way.
Create a new short cut pointing to:
C:\Windows\System32\notepad.exe C:\Windows\System32\drivers\etc\hosts
Open the properties and click the Advanced button on the Shortcut tab and select Run As Administrator.
That’s it, this will allow you to edit the file in place in notepad.
By Joe Man on February 6th, 2007 at 9:42 am #
Going to
Accessories > Right Click Notepad > Run As Administrator.
Open the file you want to modify.
thats it.
By Lars-Erik on March 21st, 2007 at 3:52 pm #
Nice to know! :) Vista’s a bit over the edge securitywise if you ask me..
By Alejandro Gonzalez on April 20th, 2007 at 9:02 am #
Security in vista is kind of excessive, specially when you’re a developer and need to be working directly on some system file or process.
By Brent Trahan on April 20th, 2007 at 9:25 am #
Being able to easily access and work with system files and processes is what made all earlier versions of Windows so unsecure but easy to use.
Things have drastically changed in the past few years that made Microsoft harden Windows Vista.
Most regular PC users will very rarely see UAC prompts once their PC has been set up and used a little.
By Ankur on July 30th, 2007 at 3:17 pm #
I have a serious problem with my Windows Vista Hosts file.
I am getting this message while I am trying to save this file.
Cannot Create c:\windows\system32\drivers\etc\hosts file.
Make sure that the path name is correct.
I have tried everything from Running notepad as administrator and even unclicking the Read Only property for my folders but no Use. Please help if anybody has any idea about this.
Thanks
Ankur
By Brent Trahan on July 30th, 2007 at 3:48 pm #
So you can open and edit your hosts file but when you go to save your changes it gives you this error?
By Dan on November 2nd, 2007 at 7:34 am #
I have the same problem as Ankur… I have disabled UAC and tried that too :( (using vista business)
By Scott on December 20th, 2007 at 4:03 pm #
thanks! very useful!!
By Joel on December 23rd, 2007 at 8:04 pm #
Check your firewall or other protective software. McAfee blocked my attempt to edit/delete the file as part of “protect network settings.”
By Justin on March 31st, 2008 at 10:26 pm #
Guys i dont have a hosts gile :(
I am using a windows vista home premium.
And idea what could be the problem.
By Brent Trahan on April 1st, 2008 at 4:38 am #
Are you positive you’re looking in the right place? There has to be a hosts file.
By Milad on April 21st, 2008 at 12:57 am #
very usefull, thank you so much
By Prem on July 24th, 2008 at 10:56 am #
Thanks Brent.
By kim on August 6th, 2008 at 10:23 am #
Thanks very much ….. at least i can alter the hosts file now….. still hate vista but hey beggers cant be choosers!!
Cheers
By j on August 11th, 2008 at 7:16 am #
Thanks, that’s useful!
Right now I’m as usual struggling against the Vista UAC, which was turned off last time I checked, in order to update this file.
I paid for this computer and am FULLY QUALIFIED to update its system resources, but MS has decided to make simple tasks difficult to impossible.
I expect my next computer will be a Mac
By jj on August 11th, 2008 at 7:31 am #
Now that I’m done complaining about Vista, I’ll offer something constructive.
One line command does the trick: C:\Windows\system32\notepad.exe C:\Windows\System32\drivers\etc\hosts
If necessary revise for any customizations, of course.
And do whatever it takes to overcome Vista UAC.
By amit on October 1st, 2008 at 4:38 am #
yes it works
By Joe Wood on November 10th, 2008 at 1:34 am #
How do I get to the Hoast file……..I have XP instead of Vista.
Better still how do I get rid of b1.adv.net if I have XP? Thanks in advance. Please email me with answer….
By rahul on December 4th, 2008 at 1:13 am #
i could not edit host file in window vista. i follow ur instructions but unable to did that, plz give me another solution its an very urgent for me
By Charon on December 12th, 2008 at 9:41 am #
It works fine and I was able to save the host-file after turning norton off.
By Brent Trahan on December 12th, 2008 at 9:54 am #
Great tip Charon.
By Lars on December 12th, 2008 at 11:27 pm #
Vista protects the hosts file and it is perfectly sane and valid that it does so.
To edit it you must do son as administrator:
Right click the shortcut of your favorite editor such as Notepad as select Run as Administrator.
From within the editor, open the hosts file (or drag and drop it into the editor).
Now you are able to save changes to it.
By Haytham on January 2nd, 2009 at 11:37 pm #
Thanks a lot!