Friday, September 26, 2008

Hosts file locked (read-only) on Server 2008

I was trying to edit the HOSTS file on Windows Server 2008 with Notepad++ but after editing it wouldn't let me save it with a "Save failed" - "Please check whether if this file is opened in another program" (the ...whether if... is their message not my typo).

Anyhow, didn't turn out to be read-only as I initially thought or another process as suggested (I did try stopping several services to see if that would help) but instead it turned out to be the fact that I hadn't started Notepad++ as administrator.

I don't understand why I need to run Notepad++ as administrator to edit the HOSTS file but aparently I do. I'm sure that it's just a matter of getting used to this new Vista style UAC that I assume is the underpinning of the security model in Server 2008.

To run Notepad++ (or any other program) as an administrator just right click on the application and select "Run As Administrator."

21 comments:

  1. what a pile of shit!, i dont know how to run notepad as animistrator, but i guess i'll figure it out

    ReplyDelete
  2. Mozey: Right click notepad or notepad++ and on the menu you'll see an option to "run as administrator"

    ReplyDelete
  3. Yeah stupid trick. I like the linux way. sudo notepad++. Here I have to change the shortcut and now ... I can overwrite anything. And thank you Microsoft for VERY clear error messages... NOT

    ReplyDelete
  4. I've followed this entry up with my reasons why you should disable UAC: guyellisrocks.com/.../disable-uac-on-

    ReplyDelete
  5. hey can i edit the host file on server 2008 n make all the peers on the LAN reference it instead of DNS server....?

    ReplyDelete
  6. To be honest i am glad they did this other wise anyone could edit the files by mistake-dont know why your being hard on MS when they did something right?RIght clicking admin is easier than going into the terminal and typing sudo any day so i dont know what the problem is?

    ReplyDelete
  7. Thank you, very helpful.

    ReplyDelete
  8. This helped me so much... Thank you!!!
    I'm a student trying to get my working environment going with Netbeans for JSP.
    -steve

    ReplyDelete
  9. It may be a problem with who owns the file or rwx persmissions

    ReplyDelete
  10. Thanks! This post was extremely helpful.

    ReplyDelete
  11. Saved me a lot of troubleshooting! :-)

    ReplyDelete
  12. p.s. happens in Windows 7 as well.

    ReplyDelete
  13. Right click on command prompt and run as administrator. Anything launched from the command prompt will be with administrative permissions. Then type "notepad" and hit enter. Ctrl-O and browse to hosts file, change notepad drop down from "Text Documents" to "All Files". Edit, save.

    ReplyDelete
  14. This fix really rocked and saved my time this Sunday.

    ReplyDelete
  15. thankyou very much! very very helpfulI

    ReplyDelete
  16. Thanks a lot, This worked!

    ReplyDelete
  17. I don't understand why this is necessary but it did work like a charm. Thanks for the tip, Guy!

    ReplyDelete
  18. I didn't find that in the menu in Win7 EE, but I worked it out through this way:
    Properties--Security
    and change the attributes in "Permissions for Authenticated Users".
    Thank you very much.

    ReplyDelete
  19. Thank you for this! You came up quickly via googling "edit hosts file read only" and this was exactly the solution I needed. Editing with UltraEdit in Windows 7.

    ReplyDelete
  20. Hi, This doesn't work for me. When I navigate to the apphost.xml through NotePad++, the file I needs doesn't show. Even though it's set to display all files.

    ReplyDelete