Run Notepad as Administrator to Avoid Access is Denied

  • NSHIMIYUMWUNGELI Antoine Marie Zacharie

One really good and really annoying feature of Windows 7 is that by default a lot of files are off-limits when it comes to editing. For example, if you try to edit the HOSTS file in Windows using Notepad, it will give you an error message saying Access is Denied. And if you try to save a text file to the root of the C drive using Notepad, you’ll also get a message saying you don’t have permission to save the file to this location:

So there’s two ways of opening files in Notepad: either you open Notepad and then open the file or you simply double-click on a file and it opens using Notepad. In this article, I’ll try to cover the different ways you can run Notepad as administrator to make your life easier, especial if you have to edit a lot of system files.

Notepad as Administrator Shortcut

If you tend to open Notepad and then open the files you have to edit, then you can create a shortcut so that Notepad will open in administrator mode automatically without having to right-click and choose Run as Administrator. That’s always one way to do it, but if you have to do that a hundred times, it can get frustrating.

So first right-click on the desktop and choose NewShortcut.

When the new shortcut dialog appears, click on the Browse button.

Next, expand Computer, then Local Disk (C:), then Windows and then choose notepad.

Click Ok and then click Next. Give your shortcut a name and then click Finish.

Now right-click on the new shortcut on your desktop and choose Properties.

Now click on the Shortcut tab and then click on the Advanced button.

Finally, check the Run as Administrator check box and click OK.

Whew! Kind of a long process for something so simple. Anyway, now whenever you click on that shortcut, it will open Notepad as Administrator. Not too bad, but this still doesn’t solve the problem of wanting to directly open a file without having to open Notepad first.

Add Open Notepad as Administrator to Right-Click Context Menu

The best way to solve the second problem is to add an option to the right-click context menu that will open the file in Notepad as administrator. This is not very hard to do, but requires a few steps. Firstly, you need to enable the built-in Administrator account in Windows 7. I won’t write all the steps here, but will simply link to a tutorial that explains it step by step:

Next, log out of your current account and then log into the Administrator account. At this time, it should have no password. Now go to Start, Control Panel and choose Create a password for your account.

Once you have chosen a password, we need to open the registry editor by going to Start and typing in regedit in the search box. Then navigate to the following key:


Now right-click on shell and choose NewKey.

Name the key the following without the quotes “Open with Notepad (as Administrator)“. Now select the newly created key and create another key called “command“. Finally, right-click on the (Default) value in the right-hand pane and choose Modify.

Change the value to the following:

runas /savecred /user:HOSTNAME\Administrator “notepad %1″

Note two things here. Firstly, you need to keep the quotes around the “notepad %1″ section. Secondly, you need to change HOSTNAME to the name of your computer. You can figure that out by going to Start, Control Panel and click on System.

So this is what mine looks like after everything:

Now, you should be able to right-click on any text file and you’ll see the Open with Notepad (as Administrator) option.

The first time you do this, you’ll be prompted for the password that you created for the Administrator account.

You won’t have to type it again because it’ll save the credentials. The only problem with this context menu shortcut is that the command prompt appears for a split second before opening Notepad. It’s not a big deal for me since it’s so much nicer to be able to open any text file as with Notepad in Administrator mode without having to open Notepad and then open the file by browsing for it. If you have any suggestions or questions, please feel free to comment! Enjoy!

uburenganzira bwose bw'uru rubuga bwihariwe na Nshimiyumwungeri Antoine Marie Zacharie © 2014 -  Hébergé par Overblog