Setting Shell Context Menu Icons


If you google something like “shell context menu icons”, I can almost guarantee that you won’t find much information on changing the icons in Windows Explorer’s right-click context menus. Actually, if you’re not afraid to edit your registry, it’s not that difficult to put icons on your own shortcut menu items, but the information on how to do it is a little scarce.

I don’t think this is Windows 7 specific, but the example I’m going to use is catered towards Windows 7 users. In Windows 7, if you use any of the “run command prompt here as administrator” examples floating around, you’re not likely to see the elevation icon appear in your context menu. This example shows how to add an elevated command prompt item to the context menu for right clicking the background of a folder, then two methods to put the elevation badge icon next to it. The second method can also be extended to put any icon you want next to a context menu item. For all instructions below, do not copy the quotes. Also, messing with your registry can mess up your computer. If you follow these instruction exactly, there shouldn’t be a problem, but if you don’t have a clue what you’re doing, backup your registry first.

To create the context menu item:

  1. Open regedit. Type “regedit” into the start menu and hit enter, or press Windows Key+R, type “regedit” and hit enter.
  2. Locate “HKEY_CLASSES_ROOT\Directory\Background\shell“. You should already see a key (the folders are keys) named “cmd” inside it.
  3. Right click “shell” and click on New->Key. Name it “runas”. By naming it “runas”, we tell Windows that this should be run as an administrator.
  4. Click on the new “runas” key, then on the right side of the window, double click on “(Default)”. Change the value to the text you want to appear in the context menu. Something like “Elevated command window” will work. Click OK.
  5. Right click in the right pane and choose New->String Value. Name it “NoWorkingDirectory”. You can leave the value blank.
  6. If you only want this to appear when you Shift+Right-Click to open the context menu, create another string value and name it “Extended”. Again, the value should be left blank.
  7. Right click again and choose New->Key. Name it “command”. This will be the command executed when you click the item.
  8. In the command key, double click on “(Default)” and change the value to cmd.exe /k pushd %V

To add the icon:

There are two ways to add the elevation badge icon. The first is probably the way you should do this, but the second will let you use any icon you want.

To add just the elevation badge icon, go to “HKEY_CLASSES_ROOT\Directory\Background\shell\runas” and create a new string value. Name it “HasLUAShield” and leave the value blank.

To add any icon you want, go to the same key and create a string value named “Icon”. Double click it and change its value to the path of the icon you want. Most default Windows icons are stored in either shell32.dll or imageres.dll inside the C:\Windows\system32 directory. You can use an icon inside a DLL by entering the path to the DLL followed by a comma, then the number of the icon. For DLLs in system folders like shell32.dll and imageres.dll, you don’t need the full path–just the name–so since the elevation badge is the 73rd icon in imageres.dll, enter “imageres.dll,73“. You can use a free tool called IconViewer to look at the icons stored inside DLLs and executables. I have not tried, but you can probably enter the path to a .ico file as well.

8 thoughts on “Setting Shell Context Menu Icons

  1. Thanks for this post. It cleared up a couple of things for me, like the mysterious “HasLUAShield”.

    I do have a question I’ve been unable to find an answer for, and I’m hoping you can help. Do you know of any way to create more than one elevated item in a single context menu (for example, an elevated “Open command window” prompt and an elevated “Take Ownership” prompt)? Is there a way to have more than one “runas”, or is there an alternative to “runas”?

  2. Sorry for the late response. I don’t think there is a way to add more than one runas, but you might be able to use the elevate powertoy to achieve the same effect. For the “Take Ownership” command, you would just make a regular action, add HasLUAShield to it, and make the command elevate "whatever the command to take ownership is"

  3. I found the answer to my question about creating multiple runas keys in a single context menu: simply name the additional keys “runas(2)”, “runas(3)”, etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.