Edit the Windows Vista Hosts File

Posted on: 01.13.07 by Brent Trahan

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

  1. Open Notepad with Administrative privileges by clicking Start, All Programs, Accessories, and then right-click Notepad and select to open as Administrator.
  2. 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.

  1. Send a shortcut to Notepad to your desktop by right-clicking Notepad in the start menu and selecting send to desktop.
  2. Right-click the shortcut to Notepad on your desktop and select properties.
  3. Click the advanced button near the bottom of the shortcut tab and check off run as administrator. Click OK in the advanced properties window.
  4. 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.

Still need help? Ask Your Computer Question Now.

16 Responses to “Edit the Windows Vista Hosts File”

  1. Munir Says:

    You also could just open your editor with administrator privileges (right-klick, “Run as administrator”).

  2. Thava Says:

    Thanks for this information.

    It was useful for me.

    / Thava

  3. ssuede8 Says:

    Thanks!

  4. Jim Says:

    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.

  5. Joe Man Says:

    Going to

    Accessories > Right Click Notepad > Run As Administrator.

    Open the file you want to modify.

    thats it.

  6. Lars-Erik Says:

    Nice to know! :) Vista’s a bit over the edge securitywise if you ask me..

  7. Alejandro Gonzalez Says:

    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.

  8. Brent Trahan Says:

    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.

  9. Ankur Says:

    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

  10. Brent Trahan Says:

    So you can open and edit your hosts file but when you go to save your changes it gives you this error?

  11. Dan Says:

    I have the same problem as Ankur… I have disabled UAC and tried that too :( (using vista business)

  12. Scott Says:

    thanks! very useful!!

  13. Joel Says:

    Check your firewall or other protective software. McAfee blocked my attempt to edit/delete the file as part of “protect network settings.”

  14. Justin Says:

    Guys i dont have a hosts gile :(

    I am using a windows vista home premium.

    And idea what could be the problem.

  15. Brent Trahan Says:

    Are you positive you’re looking in the right place? There has to be a hosts file.

  16. Milad Says:

    very usefull, thank you so much

Follow this guide's comments via RSS.

Comment pictures provided by Gravatar.

Leave a Reply

No Support Questions If you have a support question please ask it in the forum.