Set icon for custom right-click context menu item for all desktop shortcuts (windows explorer)
Asked Answered
S

4

33

I learned how to add an item to the right-click context menu, but I would like to add an icon too. I tested adding a value Icon to the key (imagine that the key is HKCL\lnkfile\shell\MY COMMAND\command, I added the icon value to HKCL\lnkfile\shell\MY COMMAND) but it doesn't work, I put the path to the icon inside it but it's 32x32, maybe is that the problem maybe no... do someone know how to add an icon to my menu item?

Thanks for any answer

Stow answered 9/9, 2010 at 22:32 Comment(0)
P
33

This might be a long shot, but try creating a String value named "Icon" under the HKCL\lnkfile\shell\MY COMMAND key, and then set the value to the path to your icon (e.g. C:\Program Files\Your Program\YourProgram.exe,0), assuming your icons are embedded in whatever application you specified to run in your command.

Pears answered 9/9, 2010 at 22:42 Comment(2)
Mhh i've tested it but it's not working... actually the exe file has a custom icon, but if I create a shortcut to that exe file the icon path is bla\bla\myexe.exe without ",0"... I've tested it too but it's not working. I'm using C# with visual studio 2010.Stow
I tested, I put the value with quotes and without, tested with a 32x32 icon and with a 16x16 icon, but still not workingStow
V
75

For Windows 7 & 8 & 10

Add custom item to Context Menu:

Sublime Text 3

Path to the application: C:\Program Files\Sublime Text 3\sublime_text.exe.

  1. Run regedit.exe (or press Windows Start Button & type: regedit)
  2. Goto:

    HKEY_CLASSES_ROOT\\*\shell
    

    (* is right at the top)

  3. Right_mouse_click shell in left panel for options to create a new Key:
    1. New > Key
    2. call it: Sublime Text 3 (or whatever you like to call it)
  4. Then we create another Key under the one we just created: Right_mouse_click Sublime Text 3 (in fact: your own app's name) in left panel for options to create a new Key:
    1. New > Key
    2. call it: command
  5. In the RIGHT panel change (Default) key value (double click or Right_mouse_click & Modify) to:

    C:\Program Files\Sublime Text 3\sublime_text.exe %1
    

    In actual fact: your own app's path.
    BUT DO ADD THE FOLLOWING AT THE END OF YOUR PATH after a space: %1.


OPTIONAL: Set Icon + Position in menu:

Icon:

  1. Click on key you created: Sublime Text 3 (Not it's child we just created: command)
  2. Create a new String Value for it (Right_mouse_click on RIGHT panel background or menu: edit, then New > Key, choose String Value)
  3. Call it: Icon
  4. Set it's value as we did for command above to:

    "C:\Program Files\Sublime Text 3\sublime_text.exe"
    

    In actual fact: your own app's path

+

Position in context menu:

  1. Create another String Value where we created Icon just as we did above
  2. Call it: Position
  3. Set it's Value to:

    Top
    

    or if you'd like:

    Bottom
    

NOTE: ICON & POSITION STRING KEYS ARE NOT CREATED IN command, BUT ITS PARENT: whatever you called your app key in \shell.

Voltmer answered 23/11, 2014 at 15:32 Comment(4)
Perfect, I was trying to do this for Sublime Text 2, so thanks for the detailed answer! ;-)Bleier
Done it on quite a few Windows 10 machines, still works. Please follow instructions carefully and it will work on Win10.Voltmer
I added Icon and Position in wrong place, in fact, if you need photos, see this link. winhelponline.com/blog/add-icon-to-right-click-menu-windows-7Denys
This method doesn't work in windows Vista, no icon shown, position not changed.Primus
P
33

This might be a long shot, but try creating a String value named "Icon" under the HKCL\lnkfile\shell\MY COMMAND key, and then set the value to the path to your icon (e.g. C:\Program Files\Your Program\YourProgram.exe,0), assuming your icons are embedded in whatever application you specified to run in your command.

Pears answered 9/9, 2010 at 22:42 Comment(2)
Mhh i've tested it but it's not working... actually the exe file has a custom icon, but if I create a shortcut to that exe file the icon path is bla\bla\myexe.exe without ",0"... I've tested it too but it's not working. I'm using C# with visual studio 2010.Stow
I tested, I put the value with quotes and without, tested with a 32x32 icon and with a 16x16 icon, but still not workingStow
S
4

Ok I've worked a bit on this and understood an important thing: If you are on Windows XP or older, you need to do a dll, create GUIDs, reference... a very long task to set only an icon to context menu

Otherwise if you have vista or seven (and it's the technique I'm using) Cory's answer works well.

Stow answered 21/7, 2011 at 8:57 Comment(0)
D
-2

simply add an entry in Registry : HKCR\Directory\shell\%MY_APPLICATION%\command\

Key name : Icon

Key value : Full path of exe (it will use application embedded icon)

Dorweiler answered 27/3, 2014 at 19:59 Comment(1)
The Icon key has to be in the parent of the command key as the accepted answer and washere's post states. BTW the accepted and correct answer was written in 2010... :)Messidor

© 2022 - 2024 — McMap. All rights reserved.