Dan
Posts: 4524
Joined: Wed Apr 24, 2013 3:51 pm

How add context menu item to Windows Explorer for folders or files

Hello,

In case you want to add context menu item to Windows Explorer for folders or files of any kind, here is what you need to do:

Explorer context menu item.png
Explorer context menu item.png (26.03 KiB) Viewed 276838 times


To achieve this, just follow the steps from the following article:

1) Create a new project of Professional type in Advanced Installer:

Create project.PNG
Create project.PNG (38.25 KiB) Viewed 276838 times



2) Select the Files and Folders view to add the application files:

Application files.PNG
Application files.PNG (20.12 KiB) Viewed 276838 times


In our demo, our application will just display the path for the delected folder or file in a message box.


Context menu option.PNG
Context menu option.PNG (6.64 KiB) Viewed 276838 times



3) Select the Registry view.

The context menu options for Windows Explorer are added through registries.

  • Context menu for right click on folders in left panel of Windows Explorer:

    Code: Select all

    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell
    right click folder.PNG
    right click folder.PNG (14.51 KiB) Viewed 276838 times



    Here is how the registry should look like in Advanced Installer:

    Folder context menu option.PNG
    Folder context menu option.PNG (30.31 KiB) Viewed 276838 times

    where Display path.exe is my exe app that will handle the folder operation
  • Context menu for right click on on background of a directory in Windows Explorer:

    Code: Select all

    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell
    background right click.PNG
    background right click.PNG (14.5 KiB) Viewed 276838 times



    Here is how the registry should look like in Advanced Installer:

    Folder background context menu option.PNG
    Folder background context menu option.PNG (33.21 KiB) Viewed 276838 times

    where Display path.exe is the exe app that will handle the folder operation
  • Context menu for right click on any file:

    Code: Select all

    HKEY_CLASSES_ROOT\*\shell
    File context menu option.PNG
    File context menu option.PNG (14.22 KiB) Viewed 276838 times


    Here is how the registry should look like in Advanced Installer:

    FileContext menu option.PNG
    FileContext menu option.PNG (26.83 KiB) Viewed 276838 times

    where Display path.exe is my exe app that will handle the file operation

In all cases:
  1. add a new key under shell, naming it as you want to name the context menu item (e.g. My context menu option)
  2. add a new key inside this key, named command (mandatory name)
  3. edit the default property in command to your executable. Also, we need to pass the path to the folder or to the file.
    • "%1" to pass the file path and name of the selected file
    • "%V" to pass the folder path and name of the selected folder
More customization:
  • Add icon: add a string value named icon for key created at step 1 with value matching an icon resource path.
  • Change menu entry location: add a string value named Position with one of: Top, Bottom

If you need to associate files with a particular extension with with your application then you can follow the steps from the Create new file extensions and make file associations.


The sample project is attached to this thread, so if you are interested to take a look directly at my project, you are more than welcome to download the ZIP file.

Hope you will find this information helpful and let us know if you want to see more samples from our side.

All the best,
Dan
Attachments
MenuItemNamePanel.zip
(12.22 KiB) Downloaded 2855 times
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Sample Projects”