Add open with Notepad as Administrator

Add open with Notepad as Administrator

So often do I work on my laptop or on servers and I have to open a file in Notepad to edit it, however the file is protected so you have to not only be an administrator but you need to use ‘Run as Administrator’

Now that’s all well and good if the menu item is there…  Try right clicking on say your hosts file and look for ‘Run as Administrator’

Run As Normal

After some digging with my favourite Sysinternals tools, I found a very simple registry file can be used to add these kinds of items

Windows Registry Editor Version 5.00

 @="Notepad as Administrator"


This adds a great new menu item that will open the file in Notepad and elevates you to Administrative credentials (initiating UAC if needed).  The key is that the bit after \shell\ MUST start with RunAs, but you can add as many as you like!  The hex piece is there as I’m using a REG_EXPAND_SZ to avoid hardcoding the path to Notepad.  HasLUAShield if present will make the UAC shield show on the menu.

I’ve used \shell\RunAs\ above so that for the likes of exe files it doesn’t show the ‘Notepad as Administrator’ option since it has a ‘Run as Administrator’ option set on the exefile.  However if you want both to show then just use say \shell\RunAsNotepad\ and you see both.

So now it looks like this:

Notepad as Admin

Happy days!  Enjoy administrative Notepad rights!