You can't modify the Hosts file or the Lmhosts file
This article provides a workaround for a problem in which you can't modify the Hosts file or the Lmhosts file.
Applies to: Windows, all versions, and Windows Server, all versions
Original KB number: 923947
Symptoms
When you try to change the Hosts file or the Lmhosts file, Windows might deny you access to the file and then generate an error message that resembles either of the following messages.
Error message 1
Access to C:\Windows\System32\drivers\etc\ hosts was denied
Error message 2
Cannot create the C:\Windows\System32\drivers\etc\hosts file.
Make sure that the path and file name are correct.
This problem occurs even though you sign in by using an account that has administrative credentials.
Workaround
Select Start > All Programs > Accessories, right-click Notepad, and then select Run as administrator.
If you're prompted for an administrator password or for a confirmation, type the password, or select Allow or Yes.
Open the Hosts file or the Lmhosts file, make the necessary changes, and then select Save on the File menu.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for