I removed read only permission from C:\Windows\System32\drivers\etc\hosts file and file is not hidden. I belong to Administrator group at Windows 7 system.

  • When I open file in gvim without admnistrative permissions by command :e C:\Windows\System32\drivers\etc\hosts and then I try to make changes messeges appear:

W10: Warning: Changes at read only file

E303: Cannot open swap file for C:\Windows\System32\drivers\etc\hosts

after :w! command message appear:

E212 Cannot open file for write

  • When I open file in gvim WITH admnistrative permissions and than open file by command e: C:\Windows\System32\drivers\etc\hosts file saves correctly by :w

What should I do to save changes using Gvim while opening Gvim without administrative permissions?

  • 2
    It's possible, but would leave the file writable for any program, even ran without administrative permissions. And that's not secure. – gronostaj Feb 28 '18 at 9:55

You must open a program with admin permissions to write to a file with restricted write access. If you're going to write to a file that requires admin permissions, you must open the program with administrative permissions before you make the change.

If you have already made changes and you want to save them rather than redoing them, I suggest you save the file elsewhere and the copy the changed one over the original.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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