How to: Edit Hosts File in Windows 7
Update: Make sure to read the valuable comments on Hosts File Editing.
For some reason, I needed to modify Hosts file in Windows 7. I went trough the same procedure which we use in XP and Vista but it was not working. In XP and Vista we follow the same procedure to edit hosts file. It should always be in mind that hosts file’s attributes are always “Read Only”. We have to open the Properties window by right clicking on hosts file and have to uncheck the Read Only attribute. Then open it in Notepad or any text editor and can modify it. But this procedure did not work when I tried to do on Windows 7.
It was in my mind that in Windows 7, we will follow same procedure and should be but it was not. I did right click on hosts file and opened the Properties window. I noticed that “Read Only” attribute is already unchecked. OK! so thought that it is good that one step is removed by default settings. I opened it with Notepad and edit it and tried to save. When wanted to save, Windows did not let me save it. Then I wanted to to replace original with Save As but again could not do.
It is clear that if we could not save it in Notepad or by using any other text editor, then what is the solution? I tried one small trick. Simply opened the Notepad and through File menu, I opened Hosts file. Now you will think that it is same again opening in Notepad but this trick worked. OK! I opened Hosts file in Notepad through File menu and edited it and saved it. I was able to save the edits in Hosts file through this trick.
Does not it feels silly that the same tool is used for editing in different ways. No, not even the different ways. One way the tool did not work and the other way it worked. I tried to justify this foolishness behavior by Googling the reason but could not. BTW, in Windows 7, Hosts file can be found here: