Newsflash

Add your items to Windows Explorer Shell context menu - it never was easier: Windows Explorer Shell Context Menu v7.14 was released

Read more...
 

Full Vista support appended

Read more...
 
Home arrow Archive arrow Add a context menu to the Windows Explorer
Add a context menu to the Windows Explorer PDF Print E-mail

Add a context menu to the Windows Explorer

Add a context menu to the Windows Explorer using Registry only.   



Introduction

Many of us like the convenience of the context menus in Windows Explorer and hate typing long paths in the command prompt window. This tool is going to address this issue by adding a new item on the context menu when you right click on a folder. You could get a command prompt that will open in the parent directory and not elsewhere. If you are not interested in the command prompt, then you can specify another executable of your choice as the target and still save some clicks and typing.

Add an entry to Explorer Shell context menu easily – How ?

 

 

 Add entries to Explorer Shell context menu with Windows Explorer Shell Context Menu

 

  Add an item to Windows Explorer Shell context menu easily with Windows Explorer Shell Context Menu. This powerful .Net component for custom items appending to Explorer Shell context menu will add all your application entries to the Explorer Shell context menu. This .Net component , C++ and Visual Basic .NET support include detailed C# and VB.NET samples, tutorials and support all you may need to add your items to context menu :

  • Add items to Windows Explorer Shell context menu to be shown on any Windows OS (all OS are supported – Windows XP, Vista, x64 , etc.)
  • Add all your items to Windows Explorer Shell context menu to be shown in any way - with custom caption and icon, as separator or sub-menu
  • Add items to Windows Explorer Shell context menu to be shown for all files or shown only for files of particular type (for example, only for .PDF .TXT , .MP3,.WMA,.AAC , .MPG media files)
  • Add your program entries to Explorer context menu, sub-menus, sub-sub-menus, sub-menus of unlimited depth and even more


Windows Explorer Shell Context Menu - is a .Net framework component that support all you may need to insert all your application items to the Windows Explorer Shell context menu - in a fast and easy way. Add all your entries to Windows Explorer Shell context menu right now – fast , easy and exactly as you prefere :

 Add items To the Explorer Context Menu in a very easy way with Windows Explorer Shell Context Menu

 

Background

Dealing with Explorer usually requires some shell programming that is not always nice. Because this method to add a context menu with your own, custom items to Windows Explorer method works only for Windows 95 / Windows 2000 (not on XP, Vista, x64 - 64-bit Windows), to add items to Windows Explorer Shell context menu you should use, according to Microsoft guidelines, appropriate .Net component - Windows Explorer Shell Context Menu. Fortunately, the hack I'm going to describe would merely set some registry entries to make this happen.


Using the code

The registry entries are the following:

private const string MenuName = "Folder\\shell\\NewMenuOption";
private const string Command = "Folder\\shell\\NewMenuOption\\command";

The code is self-explanatory and it merely sets the registry:

private void btnAddMenu_Click(object sender, System.EventArgs e)
{
    RegistryKey regmenu = null;
    RegistryKey regcmd = null;
    try
    {
        regmenu = Registry.ClassesRoot.CreateSubKey(MenuName);
        if(regmenu != null)
            regmenu.SetValue("",this.txtName.Text);
        regcmd = Registry.ClassesRoot.CreateSubKey(Command);
        if(regcmd != null)
                regcmd.SetValue("",this.txtPath.Text);
    }
    catch(Exception ex)
    {
        MessageBox.Show(this,ex.ToString());
    }
    finally       
    {
        if(regmenu != null)
            regmenu.Close();
        if(regcmd != null)
            regcmd.Close();
    }        
}

Or it deletes the settings if you don't like them anymore:

private void btnRemoveMenu_Click(object sender, System.EventArgs e)
{
    try
    {
        RegistryKey reg = Registry.ClassesRoot.OpenSubKey(Command);
        if(reg != null)
        {
            reg.Close();
            Registry.ClassesRoot.DeleteSubKey(Command);
        }
        reg = Registry.ClassesRoot.OpenSubKey(MenuName);
        if(reg != null)
        {
            reg.Close();
            Registry.ClassesRoot.DeleteSubKey(MenuName);
        }
    }
    catch(Exception ex)
    {
        MessageBox.Show(this,ex.ToString());
    }
}

The rest of the code only provides a sane user interface.



Add a context menu to the Windows Explorer - Discussion

General    Is it possible to added a menu hierarchy?
    
How would I add a Menu Option that when you select it, it expands to multiple options?
General    Re: Is it possible to added a menu hierarchy?    member    dmihailescu    16:25 6 Jun '08  
    
in short, there is no easy way.
You'll need to have some shell extensions(COM objects).
I saw some good articles on this site about .net plug ins.
General    Registry Entry throught Setup And Deployment Project
    
How can I make an registry entry through the Setup and Deployment projects as in the described order in this article?
General    Re: Registry Entry throught Setup And Deployment Project
    
export the reg keys using regedit and add them to the deployment script.
The non default path might be an issue.
Windows Explorer Shell Context Menu
General    Re: Clicking on drive    member    dae22000    13:58 9 Oct '07  
    
Hi, anyone know how it can be configured to run from a drive? - e.g. by right clicking on local disk? I'm getting "Windows Application has encountered a problem and needs to close". Many thanks.
Windows Explorer Shell Context Menu
Question    context menu in applications (notepad, word ..) [modified]    member    balu234    3:11 19 Sep '07  
    
is there any way to add the context menu items for the applications like MSWord, EXcel, notepad etc ??


-- modified at 8:21 Wednesday 19th September, 2009
Windows Explorer Shell Context Menu    2.50/5 (2 votes) Rate this message: vote 1 1 2 3 4 5 vote 5
Answer    Re: context menu in applications (notepad, word ..)    member    dmihailescu    7:53 20 Sep '07  
    
Yes, I did something like that for zip files here:http://www.codeproject.com/useritems/cpzipstrip2.asp[^]
Windows Explorer Shell Context Menu
Question    Re: context menu in applications (notepad, word ..)    member    balu234    21:52 20 Sep '07  
    
Hi,
Thanks for the reply [Smile]
Can I program to edit/modify the context menu, after opening the applications notepad/msword/excel etc.
Like when I open a notepad I will get a context menu with Undo,Cut,Copy,Paste,delete,Select all. Can I include my command at there ?? which will open my application from there.
Windows Explorer Shell Context Menu    2.00/5 (2 votes) Rate this message: vote 1 1 2 3 4 5 vote 5
Question    Context menu order    member    twsabonrai    6:50 19 Feb '07  
    
When I add a new menu option using these techniques, it is at the top of the context menu and is the default option. I don't want this.

How do I insert the new menu option elsewhere in the menu and leave the default menu option alone?
Windows Explorer Shell Context Menu
Question    Command arguments    member    Mith-Randir    6:49 26 Sep '06  
    
I need to pass some arguments (this includes the path to the right-clicked file) to the program that'll fire up when slecting the menu item that i create.
Please help.
Excuse my english

All we have to decide is what we do with the time that is given to us.
All that once was is lost for few now live who remeber it.
I know that you have other rules, but I obey no rule.

Windows Explorer Shell Context Menu
Answer    Re: Command arguments    member    dmihailescu    7:55 20 Sep '07  
    
I did just that at: http://www.codeproject.com/useritems/cpzipstrip2.asp[^]
Windows Explorer Shell Context Menu
Question    how can i control in event handler    member    syriast    4:05 31 Jul '06  
    
please tell me how can i contro in event handler to do
1- when we stop on file cklic in right we show my app in context menu whin cklic on it icon send the fike to my application not open it
Windows Explorer Shell Context Menu    2.00/5 (1 vote) Rate this message: vote 1 1 2 3 4 5 vote 5
Question    get code in vb.net    member    syriast    3:07 31 Jul '06  
    
can i get the same code but in vb.net pleasor tell me how make my app set in windows context menu whin it setup please
Windows Explorer Shell Context Menu
Answer    Re: get code in vb.net    member    dmihailescu    7:50 20 Sep '07  
    
try converting to vb.net using http://www.tangiblesoftwaresolutions.com/Product_Details/Instant_VB.htm[^]
Windows Explorer Shell Context Menu
Question    How do I set up the registry key value to allow for multiple file arguments?    member    MartyP    17:19 21 Apr '06  
    
Hello,

How would I set up the registry key value to allow for multiple files as arguments? I've tried, with and without quotes:

application.exe "%1"
application.exe "%L"
application.exe "%l"

But I only get one argument in the external application.exe program for all of these cases.

Does anyone know what to append after the application path?

Warm regards,
MartyP

-- modified at 20:20 Friday 21st April, 2006
Windows Explorer Shell Context Menu    2.00/5 (1 vote) Rate this message: vote 1 1 2 3 4 5 vote 5
Answer    Re: How do I set up the registry key value to allow for multiple file arguments?    member    MartyP    12:54 29 Apr '06  
    
I recenently learned that the only way to do this is to create a Context Menu Handler inside a COM DLL: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_int/shell_int_extending/extensionhandlers/contextmenuhandlers.asp
Windows Explorer Shell Context Menu
General    Add an icon for the context menu entry    member    FrEaK_CH    16:19 1 Jan '06  
    
Hi

How can I add an icon for the context menu entry? Is that possible? [Confused]

Thanks
Dominik
Windows Explorer Shell Context Menu    1.50/5 (2 votes) Rate this message: vote 1 1 2 3 4 5 vote 5
General    Re: Add an icon for the context menu entry    member    MartyP    12:52 29 Apr '06  
    
I believe the only way to do this is create a Context Menu Handler inside a COM DLL: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_int/shell_int_extending/extensionhandlers/contextmenuhandlers.asp
Windows Explorer Shell Context Menu
Question    How do i write for only JPG/JPEG images    member    Maheswara Raju    6:11 17 Oct '05  
    
this article is really useful. i tried the both "Folder" and "*" it works fine. i have a requirement of showing the context menu only for JPG / JPEG images. please guide me how to do that.

Thanks and Regards
Maheswara Raju

Maheswara Raju

-- modified at 9:41 Monday 17th October, 2005
Windows Explorer Shell Context Menu
Windows Shell Context Menu
Answer    Re: How do i write for only JPG/JPEG images    suss    Anonymous    19:41 18 Oct '05  
    
Try *.jpg instead of *.
Windows Explorer Shell Context Menu
1.00/5 (1 vote) Rate this message: vote 1 1 2 3 4 5 vote 5
General    How do I get the folder selected?    member    Martin Lundberg    14:45 2 Oct '05  
    
Hello!

I want to add the selected folder as an argument to my application, how do I get the folder?

Thanks in advance!

~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden

Windows Explorer Shell Context Menu
General    Re: How do I get the folder selected?    suss    Anonymous    19:28 4 Oct '05  
    
In your app, in the main()
try this:
string CrtFolder = Environment.CurrentDirectory;
It might work.
Windows Explorer Shell Context Menu
2.00/5 (1 vote) Rate this message: vote 1 1 2 3 4 5 vote 5
General    Re: How do I get the folder selected?    member    Martin Lundberg    22:18 4 Oct '05  
    
Hello!

Thanks for answering me, however I've allready found another solution. In my setup project I set the registry keys needned and use the [TARGETDIR] variable to get the directory where the user installed the application. Then I add %1 after it which is the selected folder.

Ex: [TARGETDIR]MyApp.exe %1

Thanks anyway!

~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden

Windows Explorer Shell Context Menu    3.00/5 (2 votes) Rate this message: vote 1 1 2 3 4 5 vote 5
Question    Re: How do I get the folder selected?    member    Simonknight6600    9:40 29 Mar '06  
    
Hello!

It doesn't work in my application. Environment.CurrentDirectory contains the parent directory of the selected one. What should I do?

Thanks,
SimonKnight


Windows Explorer Shell Context Menu
Answer    Re: How do I get the folder selected?    member    Simonknight6600    7:34 30 Mar '06  
    
I have found the mistake [Smile] . You should add %L to the value of the registry key 'Command'.

So, replace this line of your code inside the method btnAddMenu_Click:

regcmd.SetValue("",this.txtPath.Text);

with this one:

regcmd.SetValue("", this.txtPath.Text + " %L");

Now you can get the selected file/folder by the args variable inside the main() method.

I hope, you understand my bad English [Wink]
SimonKnight6600
Windows Explorer Shell Context Menu
General    Re: How do I get the folder selected?    member    dbsmilr    10:06 27 Jul '06  
    
Once we can get the folder/file selected, how do we access that in the target command exe program?

This is what I'm trying to do:
1. add context menu to windows explorer, "Create Backup"
2. create a program that copies the selected file or folder and moves it to "origFileName.ext_BKP_20060604" in the same directory as the selected folder.

Any ideas? Thanks!!!
Windows Explorer Shell Context Menu
General    Re: How do I get the folder selected?    member    otakon    7:54 27 Oct '06  
    
%1 at the of the command
Windows Explorer Shell Context Menu
Answer    Re: How do I get the folder selected?    member    Liujuan    22:21 16 Jul '07  
    
We should add "" for the %L, because when there is space(s) in the filename, the filename will be broken into sevral parameters. So it should be
regcmd.SetValue("", this.txtPath.Text + " \"%L\"");
and get the path by
Main(string[] args)
{
string SelectedPath=args[0];
}

I'm a C# programmer

Windows Explorer Shell Context Menu    2.00/5 (1 vote) Rate this message: vote 1 1 2 3 4 5 vote 5
General    How about files???    member    dotnetvirgin    0:37 9 Jun '05  
    
This is great for right clicking on a folder, but doesn't work on files.

I would like to click on any file(s) and bring up a program passing that as a parameter. Is there a similar registry hack, or am I in for hundreds of lines of code?
Windows Explorer Shell Context Menu    2.00/5 (2 votes) Rate this message: vote 1 1 2 3 4 5 vote 5
General    Re: How about files???    member    dotnetvirgin    0:41 9 Jun '05  
    
It's OK, worked it out, less than a minute after posting this.

Just replace Folder with *, so "*\\shell\\NewMenuOption"

Works a treat.
Windows Explorer Shell Context Menu    3.25/5 (4 votes) Rate this message: vote 1 1 2 3 4 5 vote 5
General    Re: How about files???    member    AnandChavali    22:16 31 May '07  
    
Place the command under "HKEY_CLASSES_ROOT\\AllFileSystemObjects\\MyCommand\\command"

It will work for all objects...

Thanks and Regards,
Anand.

Windows Explorer Shell Context Menu    3.50/5 (2 votes) Rate this message: vote 1 1 2 3 4 5 vote 5
General    Re: How about files???    member    viennarc    9:54 11 Nov '07  
    
Hi dotnetvirgin,

I have the same problem to open a file with my program by right clicking on that file in the explorer.
Did you get the problem solved yet?
I know that it also works with the ClassesRoot directory of the Registry but I have forgotten the exact position (prbably in the subdirectory * ?).

With best regards,
viennarc


You wrote:
Forum Add a context menu to the windows explorer
Subject: How about files???
Sender: dotnetvirgin
Date: 3:37 9 Jun '05
This is great for right clicking on a folder, but doesn't work on files.

I would like to click on any file(s) and bring up a program passing that as a parameter. Is there a similar registry hack, or am I in for hundreds of lines of code?

 
< Prev   Next >
© 2010 Add items to context menu, add entries, add programs and commands -
Easily with Windows Explorer Shell Context Menu .NET Component (C#, VB, C++, VB.NET).
All product and company names are trademarks or registered trademarks of their respective owners.