31

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.

David Sulpy
  • 4,089

6 Answers6

33

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

slhck
  • 235,242
Frederik
  • 458
10

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".

Massimo
  • 2,679
3

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!

Frankl
  • 31
2

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.

Peter
  • 21
2

Copy the hosts file to another location on the PC (like Documents) and edit in that location. copy hosts file back to original location. Worked for me.

user255834
  • 21
  • 1
0

Running as admin didn't work in Windows 8 for me. Here's what I did to solve the problem:

  • Disconnect from net by unplugging network cable (or disable wireless)
  • Find hosts file. right click --> properties --> security
  • Click Users then edit
  • Add write for users (admin has write but didn't work)
  • Edit file by running notepad as admin
  • Save file
  • Remove write for users
  • Reconnect to net.
James Mertz
  • 26,529
nero
  • 11