none
Unable to edit Hosts file in Win7 Home Prem 64bit.

    Вопрос

  • Clean install.  Administrator account.  Unable to edit the permissions of the hosts file. There is one in the drivers\etc file, which I cannot edit. There is supposed to be one in %systemroot% \SysWOW64\drivers\etc   but there is no etc folder in the drivers folder.

     Turned off DNS Server. gpedit.msc not found when calling it in "run".  This is the first time I've used 64bit anything, so a bit of a newb in that respect. 

    Any ideas?
    • Перемещено Ronnie VernonMVP, Moderator 22 октября 2009 г. 18:45 Focus (From:Windows 7 Installation, Setup, and Deployment)
    22 октября 2009 г. 18:38

Ответы

  • Hi Dawnybros,

      I think your issue is happening because Windows uses split security tokens when you are logged on with the Administrator account and have UAC on. This means that normal actions will use a standard user token, and only actions that are explicitly marked as needing admin rights will use an Admin token. So, when you open a file in Notepad.exe, it will use the standard user token. The problem is, the Windows directory is protected from writes unless you have appropriate privileges, and a standard user does not. However, this is easy to work around:

    1. Type Notepad.exe in the search box, so that it appears in the program list (or browse to it)
    2. Right-click Notepad.exe and choose Run as Administrator
    3. Now browse to the HOSTS file and open it in the elevated Notepad instance. Now it should save fine.

    As for Gpedit.msc, I am pretty sure that is not included in any Home version of our operating systems, including XP or Vista.

    Tim Newton
    22 октября 2009 г. 20:05
  • Hi,

     

    Tim is right. GPEDIT.MSC is not included in Windows 7 Home Premium.

     

    For the permission issue, I suggest you also try the following steps.

     

    Take ownership of the hosts file and change the permission for it

    =================================

    1.    Right click on hosts file and click “Properties”.

    2.    Switch to “Security” tab and click “Advanced” button.

    3.    Switch to “Owner” tab and click “Edit…”.

    4.    Highlight your user account or administrators group and click “OK” twice to quite the “Advanced Security Settings” dialog box.

    5.    On the “Security” tab of “Properties” dialog box, click “Edit…”.

    6.     Highlight Administrators group, check the box for “Full control” under “Allow” and click “OK”.

     

    What’s the result?


    Arthur Li - MSFT
    23 октября 2009 г. 9:45

Все ответы

  • Hi Dawnybros,

      I think your issue is happening because Windows uses split security tokens when you are logged on with the Administrator account and have UAC on. This means that normal actions will use a standard user token, and only actions that are explicitly marked as needing admin rights will use an Admin token. So, when you open a file in Notepad.exe, it will use the standard user token. The problem is, the Windows directory is protected from writes unless you have appropriate privileges, and a standard user does not. However, this is easy to work around:

    1. Type Notepad.exe in the search box, so that it appears in the program list (or browse to it)
    2. Right-click Notepad.exe and choose Run as Administrator
    3. Now browse to the HOSTS file and open it in the elevated Notepad instance. Now it should save fine.

    As for Gpedit.msc, I am pretty sure that is not included in any Home version of our operating systems, including XP or Vista.

    Tim Newton
    22 октября 2009 г. 20:05
  • Hi,

     

    Tim is right. GPEDIT.MSC is not included in Windows 7 Home Premium.

     

    For the permission issue, I suggest you also try the following steps.

     

    Take ownership of the hosts file and change the permission for it

    =================================

    1.    Right click on hosts file and click “Properties”.

    2.    Switch to “Security” tab and click “Advanced” button.

    3.    Switch to “Owner” tab and click “Edit…”.

    4.    Highlight your user account or administrators group and click “OK” twice to quite the “Advanced Security Settings” dialog box.

    5.    On the “Security” tab of “Properties” dialog box, click “Edit…”.

    6.     Highlight Administrators group, check the box for “Full control” under “Allow” and click “OK”.

     

    What’s the result?


    Arthur Li - MSFT
    23 октября 2009 г. 9:45
  • Tim is correct and his method will work. Another way to do this is to drag a copy of the hosts file onto your desktop. Open it in Notepad, make your edits, and save the file. Drag the copy back to its original location. When asked if you want to replace the original, say YES. Then you'll get an elevation prompt from UAC. Acknowledge the prompt and the edited hosts file will replace the original file.

    This works because when you copy the hosts file to the desktop, the permissions on the copy will allow editing by the standard user.
    23 октября 2009 г. 13:32
  • Very true Arthur, you can certainly do it that way. However, I prefer not to mess with permissions if I can help it, especially something within the system directory. Using the Notepad method is quick (just one extra click) and also temporary since as soon as you close Notepad the Administrator token is discarded.

    Tim Newton - MSFT
    23 октября 2009 г. 17:59
  • As an update to this, if trying to edit the "hosts" file in Win 7 64:

    Found this on wiki, and it appears to be true. I personally created the hosts file in this location, and it looks like it has done what I was looking for.

     

    "Windows 64bit:  SystemRoot%\system32\drivers\etc\ 

    (Many sources, including several Microsoft support pages, will incorrectly state that the hosts file is at%SystemRoot%\SysWOW64\drivers\etc\)"

    from: http://en.wikipedia.org/wiki/Hosts_(file)

    • Изменено Doc_Edit 14 марта 2011 г. 14:31 Clarity
    14 марта 2011 г. 14:29
  • I tried to elevate the both notepad and cmd but still no luck, so I edited the host file from safe mode, it works perfectly.
    20 января 2012 г. 5:58
  • i honestly love you so much you dont understand how you helped me out ! thanksss!! you're the best i'd marry you if i could
    27 января 2012 г. 1:45
  • Dose not work for me at all.

    I run note pad as administrator - still get access denied.
    I can not change ownership or permissions of the file or the folder, even when antivirus is turned off.
    Even running in safe mode did not help.
    15 июня 2012 г. 19:02
  • Paulg3:

    Try the method that I described in my post above. At the moment, the post is the sixth one from the top.

    16 июня 2012 г. 2:14
  • Hi,

    As you would know, some of the Windows 7 users can’t save the host file how they like it. The host file itself will simply vanish what the user had done with it.

    In my scenario, I was unable to fix this even after all the instructions provided in above posts. Hence, I have come up with my own idea and luckily it worked.<o:p></o:p>

    For those users who experience this problem, here are the instructions to fix it.

    First of all, you should have the administrative privileges to edit the host file. In normal case, if an admin user directly go to the host file in system 32 and add his preferences and then save it, it should keep the changes. However, in some wicked scenarios, it will not. I had done a detailed research on this through all the available online forums and even contacted Microsoft several times with no luck.

    So, here you go with a correct solution for this problem.

    Note: If you are not comfortable with Windows OS and don’t know what you are doing, this process can mess up things. Hence, do not attempt if you are not 100% sure you can make it.

    • Login to an administrator account.
    • In the run command (Windows key + R) type, “control folders” and hit enter.
    • Click on the tab called view.
    • Select the radio button for Show hidden files, folders and drivers –ON.
    • Uncheck the ‘Hide extension for known file types-ON
    • Click on Apply and then OK.
    • Type “drivers” in run command and hit enter. It will take you to where the folder “drivers” located in System 32.
    • From the “drivers” folder, double click the folder named “etc.”
    • Now you can see the “host” file along with others.
    • Now, in the search area in start menu, type “notepad.exe” and open the notepad.exe as administrator. (In order to do this, you can right click on the notepad.exe shown and select “Run as Administrator.” If UAC prompted, click YES/OK)
    • Now, you will have a notepad open with administrative privileges.
    • At the top left side of the notepad click on “file” and then select “Open.”
    • A box will appear which will allow you select the file to open. Carefully, navigate to the location where the “host” file is located. To do that, select the drive where you installed Windows. If you have the Windows installed in C: select ‘Local Disk (C :)’ > Windows > System 32 > drivers > etc. At this point, you might not have another option to proceed or select from. The window would be empty. To proceed further, select the option “All files” from the drop down menu which is located above the “Open” and “Cancel” button. You can now see all the files located in etc folder.
    • Select “hosts” from the menu and click on “Open.” Note: You can either click on open or double click on the file.
    • Now, you will have the host file information open in the notepad which you had already initiated before with administrative privileges.
    • Make whatever changes you as you wish. (Example: If you need to block a web site called www.block123.com you can type 127.0.0.1 www.block123.com right under the local hosts. Make sure you do not change any other letters or characters which are already saved in host file. This will completely mess up your computer. For more information on the information about host file, refer the Microsoft web site: http://support.microsoft.com/kb/972034 . If you have accidently delete/edit anything from host file, please delete the complete information stored in host file and copy and paste the host file information from Microsoft which is appropriate for your Operating System.)
    • Click on “file” again and select “Save as” and save it in etc. If the path is showing correct to etc folder, save it to etc. If it is navigated to somewhere else, follow the instructions provided above and select etc folder and then save it.
    • Now, go back to the actual host file location which is in System32 > Drivers > etc (You would have it already open if you had followed the instructions just like the way I have provided)
    • There you can see 2 host files. One which has already been there and the other one you just saved.
    • Among the two, one is called “hosts” and the ‘type’ would be ‘file.’ This is the original host file. The other which you have just saved will be named as “hosts.txt” with the file type as ‘Text Document.’
    • Right click on the original host file and select rename. You can even click on that file and press F2. This will enable the option to rename the file. Rename the original host file as “hostold” and hit enter.
    • Now, select the second host file which we have saved as a text document and rename it as “hosts.” Make sure that you DELETE the .txt file extension in order to change the type “Text Document” to “File” and hit enter.
    • Now, you have successfully saved the host file with your preferences.
    • You can now delete the file which we renamed as “hostold.”
    • We are done. You would need to do this process all over if you need to edit the host file again. I know it is difficult, however, it is our own requirement and we have to invest few minutes on this.
    • Enjoy your computer with a great feeling that you have finally edited the host file as per your wish and take it from here. Wish you luck.

    Should you have any questions, please feel free to ask.

    • Предложено в качестве ответа Louisesf 13 сентября 2012 г. 21:31
    8 августа 2012 г. 1:49
  • This worked.  Excellent clear instructions.  Thanks.
  • but i can't rename this original host when i rename i hit enter but the systeme said recommencer plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz help tha't file make's me crazyy

    21 августа 2013 г. 14:05
  • I right clicked on the hosts file (in safe mode) and unchecked read-only. I was then able to edit the file in Notepad. Once saved, I re-checked the read-only. Seems to have worked for me.

    c

    13 декабря 2013 г. 19:04
  • Did not work:

    Access denied



    • Изменено skābene 15 июля 2014 г. 19:01
    15 июля 2014 г. 19:01