How to open a file for editing in Administrator mode?

I have .config files set to open in Notepad++. The files I edit are typically in protected locations (e.g. c:\windows\, c:\program files..., etc..) thus requiring administrator access.

I'd like to be able to double click on a .config file and have Notepad++ open with Administrator privileges. It's fine if the UAC prompt comes up.

Is there a way to do that?


Solution 1:

The best way to is to go straight to the folder in which Notepad++ is installed (Program Files for 32 bit Windows and Program Files(x86) for 64 bit Windows), there, find the Notepad++ executable, right-click on it, and select Compatibility, and at the bottom check the box for Run as administrator.

This WILL make your application always pop up with a UAC warning, but you'll always have the ability to edit as administrator.

Good luck!

EDIT: Found this article which allows you to create the shortcut without launching the UAC prompt. It's technically for Windows 10, but should work the same way on Win7+.

Solution 2:

I have found that searching for the editor program (e.g. Notepad++) in the Start menu and then typing Ctrl+Shift+Enter lets you run the program as an administrator.

You should then be able to open and edit the file that requires elevated priviledges.

Solution 3:

As an improvement over @Askeli's answer, you can first make a copy of the notepad++ executable (Name it something like NotepadUAC). Then set the compatibility mode in the properties of your copy to require administrator mode as suggested by Askeli. Now you should also be able to set your .config files to open up using the copy rather than the original.

The advantage here is that you won't see the UAC prompt when opening files with the original (default) Notepad++ .exe file. The disadvantage is that this copy isn't necessarily going to keep itself up to date in the same way as the original, and might eventually cause problems with mismatched .dll or config versions. But it's always easy enough to uninstall/reinstall if that happens.