How to Edit Hosts File in Windows 7 and Vista

System Administrators who are following my tutorial to block twitter, facebook and other social networking sites have complained that the trick doesn’t work on Windows 7 and Vista as they can’t edit the Hosts file. Whenever they try to edit the Hosts file on Vista, they get the error, make sure your path name is correct, while saving the file. The fact is that you can still block social networking sites on Windows 7 or Vista using Hosts file, you just need to edit it as an administrator. Here’s how to do this-

Editing Hosts File in Windows 7 and Vista

1. Go to Start > All Programs > Accessories, right click on Notepad and select Open as Administrator.

2. Now you’ll have a notepad that is running as an administrator. Go to File > Open, browse to C:\Windows\System32\drivers\etc. Select All Files from the drop down just above the Open button and then open the Hosts file for editing.


Now just save the Hosts file after you are done, and you’ll not see any error this time.

This trick also applies to other files as well. If you can’t save a file after editing in Windows 7 or Vista, just edit it as an administrator.

4 thoughts on “How to Edit Hosts File in Windows 7 and Vista”

  1. Have tried this and another lot of tips but doesnt work for me at all. Did manage to get it to block facebook on one occassion but stopped blocking spontaneously after a couple of days. Cannot get Vista to block webites using the above method even tried flushing DNS and disabling UAC bit still not getting anywhere!!!!!!!!
    Any tips to get it working would be appreciated

  2. @Ross

    This should work on Vista. Maybe you are using some program like spybot that is modifying the hosts file. Next time it stops working, check hosts file to see if the entry is there.

  3. hey i tried these trick in my clients pcs because they have the path of “hosts” file so then after they are changing everyday and use the blocked websites so r u having another tricks to block websites pls pls pls send me the tricks so i can block the website…

Leave a Comment