How to open a file for editing in Administrator mode?

231,135

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.

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

Solution 4

My solution was to pin Notepad++ to the taskbar. When I need it for system files editing I right click on it, click on "Notepad++", and click on "Run as administrator".

The other solutions modifying the shortcut or making copies of it are fine if you are editing system files all the time. I use Notepad++ on a daily basis but I don't mess with protected files every day.

Solution 5

This wasn't available when the original question was posted in 2010, but as of 2012 - the best answer (at least as I consider it):

Install nppSaveAsAdmin:

From http://sourceforge.net/projects/nppsaveasadmin :

This plugin allows you to save any file as administrator. Just press "Save" in Notepad++ and if you are not allowed to change this file as user, Notepad++ will save it as administrator. Windows XP, Windows Vista, Windows 7, Windows 8 are supported.

The "Save as admin" plugin is available for quick and easy installation from the Notepad++ Plugin Manager. (Plugins / Plugin Manager / Show Plugin Manager / Available. Check "Save as admin", click "Install".)

Notepad++ will continue to run as usual, and without needing to run with full administrative UAC tokens. However, if Notepad++ sees that you're trying to save a file that you are otherwise not allowed access to, it will fork to NppAdminAccess.exe (displaying a UAC prompt). Simply click "Yes", and your file will be saved with administrative privileges.

Share:
231,135
gardenofwine
Author by

gardenofwine

Updated on September 17, 2022

Comments

  • gardenofwine
    gardenofwine almost 2 years

    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?

  • gardenofwine
    gardenofwine over 13 years
    @akseli's suggestion works, however, I still see the UAC prompt. Anyway, I can live with it.
  • ctusch
    ctusch almost 12 years
    @Ramhound Would you please care to check out the linked article and rethink your downvote? Or alternatively point out which answer you are referring to? akseli's answer will always trigger UAC. Joel Coehoorn's answer needed a copy of the .exe file (which won't get automatically updated, as he mentioned). Also it will also always trigger UAC for the specific file type. Marlon's answer just starts the program as admin, you still need to open the file manually in Notepad++. And notepadpp studend user's answer is off-topic AFAICT.
  • elolos
    elolos over 11 years
    You 're right, you open the file from within the editor this way and not by double click.
  • Joel Coehoorn
    Joel Coehoorn over 11 years
    We can improve on this by making a copy of the Notepad++ exe file, and setting only the copy to run as administrator. This way, the regular notepad++ won't prompt you every time.
  • Bernhard
    Bernhard almost 5 years
    and like superuser.com/a/1462628/193963 put both shortcuts to the shell sendto menu
  • Arturs Radionovs
    Arturs Radionovs about 4 years
    Why doesn't Notepad.exe have this option?