Add open with Notepad as Administrator
-
Twan van Beers
-
09 March, 2018
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’

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 [HKEY_CLASSES_ROOT\*\shell\RunAs] "HasLUAShield"="" @="Notepad as Administrator" [HKEY_CLASSES_ROOT\*\shell\RunAs\command] @=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\ 00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6e,00,6f,00,\ 74,00,65,00,70,00,61,00,64,00,2e,00,65,00,78,00,65,00,20,00,22,00,25,00,31,\ 00,22,00,00,00This 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:

Happy days! Enjoy administrative Notepad rights!
Twan van Beers
Twan is a senior consultant with over 30 years of experience. He has a wide range of skills including Messaging, Active Directory, SQL, Networking and Firewalls. Twan loves to write scripts and get deep and dirty into debugging code, in order to understand and resolve the most complex of problems.
News & Insights
Trusted insights on technology and innovation to power your business growth.
-
03/06/2026
A practical engineering guide to owners, assignment, consent, credentials and ...
Read More
-
19/05/2026
Domain migrations in Microsoft 365 are rarely as simple as shifting email ...
Read More
-
12/05/2026
Over the past 10 to 15 years, Microsoft 365 has fundamentally reshaped how ...
Read More
-
07/05/2026
Yesterday we had an all company meeting and I thought it would be cool to kick ...
Read More
-
07/05/2026
Planning a tenant-to-tenant migration? Talk to us
Read More
-
31/03/2026
In tenant-to-tenant (T2T) and Google-to-Microsoft 365 migration projects, ...
Read More
-
27/03/2026
You’d think this would be easy and not an uncommon request. There are genuine ...
Read More
-
23/03/2026
Managing Google to Microsoft Migration with GAM7 and PowerShell
Read More
-
16/03/2026
When a user leaves an organisation in Microsoft 365, administrators have ...
Read MoreSubscribe to our newsletter for the latest updates and insights.
Like what you see? Stay in touch! Subscribers to our email list are among the first to receive the latest news, views and updates from Nero Blanco