Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to edit my hosts file in Windows 8 Pro. When I open C:\Windows\System32\Drivers\etc\hosts in notepad++ or any other text editor, make changes and attempt to save, I get a dialog that tells me "Save failed: Please check if this file is opened in another program."

I can't think of what would be using it (other than a browser, iis, and windows defender). I've never encountered this problem in Windows 7. I have used Process Explorer to try and identify any processes that are currently using the Hosts file but when I search Process Explorer for the "Handle or DLL substring" 'hosts' it doesn't return anything. I've looked around Process Explorer to see if there is any other way to search for processes consuming the file, but haven't had any luck.

I've also tried simply stopping the Windows Defender service and stopping the WWW Service.

Any suggestions would be greatly appreciated!

share|improve this question
1  
Process Explorer itself has been known to sometimes keep a file open. Also make sure you run notepad As Administrator. I've had no issues editing hosts file in win8. – Bret Fisher Sep 18 '12 at 16:17
Windows 7 != Windows 8. Don't assume that something that works in 7 will work in 8, or that it will work the same way. – joeqwerty Sep 18 '12 at 16:19
   
Running as Administrator was the answer, Thanks Bret. – David Sulpy Sep 18 '12 at 16:27
@joeqwerty - You couldn't be more wrong. – Ramhound Sep 18 '12 at 19:16
1  
Wrong to not make the assumption that Windows 8 works like Windows 7? My comment wasn't regarding the actual task of editing the hosts file but in the statement that "I never had this problem in operating system X". Any time you assume that tasks/operations you performed in a previous version of the OS will work the same in the next version of the OS is about the time you start going off in the wrong direction. – joeqwerty Sep 18 '12 at 19:45

migrated from serverfault.com Sep 18 '12 at 16:34

4 Answers

up vote 13 down vote accepted

You have to run Notepad++ as administrator. Otherwise you won't have the neccessary permissions to edit that file.

share|improve this answer
Is there any way to make it so you don't have to run as admin to edit that file? – Saturn2888 Sep 18 '12 at 17:48
Not that i'm aware of. – Frederik Nielsen Sep 18 '12 at 18:31
@Saturn2888 I would highly advise that you not change the permissions. Otherwise, A virus could hijack all of your webbrowsing by injecting DNS entries into it for the websites you go to, and redirect you to malicious websites. – Darth Android Sep 18 '12 at 18:51
If you're frustrated with the whole Run as Admin thing here's how you can use the Shell Extension shortcut to do this: 1) Right click hosts file -> Open in Notepad++ 2) Close Notepad++ 3) Run Notepad++ as administrator. The file should be still open as N++ remembers the last file(s) you had open. Saves you digging through the file-open dialog. – Aren B Sep 18 '12 at 19:48
@Aren B Sadly, Notepad++ run as admin completely forgets all tabs I had open as a user. It's really annoying. – Saturn2888 Sep 22 '12 at 1:52
show 1 more comment

If you actually have administrator rights, then you're probably fighting against UAC. Make sure to launch your favorite text editor by right-clicking on it and selecting "Run as administrator".

share|improve this answer
Great point. I am running as a user with administrative rights. – David Sulpy Sep 18 '12 at 16:40

You may also want to check your permissions on the host file itself. You may run as administrator but you may not have the rights to edit the file.

share|improve this answer

I had the same case, and couldn't change the hosts file even after I checked if I had all the permissions in the user settings or the hosts file's permissions.

ANSWER: Some antivirus software (in my case AVIRA)blocks everything in changing hosts files in their security options. Disable it for a minute, and change. Be careful, it can be risky!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.