Creating a context menu in Explorer which sends multiple file arguments to an external application

Posted on 2006-04-24
Last Modified: 2013-12-03
Hello experts,

I've created an entry in the registry using a program written in C# which adds another program I've written, I will call it argument_acceptor.exe, to the context menu of Windows Explorer, and I need this program to accept all of the file arguments passed to it.

The path which I used to create a context menu item for the application is HKEY_CLASSES_ROOT/*/shell/Application Name/Command. Also I made a duplication at HKEY_CLASSES_ROOT/Folder/shell/Application Name/Command to create a context menu for directories.

The default value of these keys are set to

argument_acceptor.exe %1

However, if I select more than one file/folder and click on the context menu item this doesn't send all of the arguments to it. I've also tried, with and without quotes:

argument_acceptor.exe "%L"
argument_acceptor.exe "%l"

but I only get one argument in the external argument_acceptor.exe program for all of these cases, or sometimes the argument_acceptor.exe program crashes when I try to send multiple files.

Does anyone know what to append after the application path or did I just make the argument_acceptor.exe program incorrectly?

The argument_acceptor.exe program is pretty straigtforward, just:
        static void Main(string[] args)
            foreach (string arg in args)

Question by:Marty83902
    LVL 86

    Accepted Solution

    If you want that functionality, you'll need to create a ContextMenuHandler inside a COM DLL (see "Creating Context Menu Handlers"). You'll then receive all selections in your 'InvokeCommand()' implementation, which you can use to build a complete command line to call your application.

    Author Comment

    Thanks. Too bad it can't be done by just setting the registry key to a certain value, but it looks like I might have to pour through all of the extra stuff for setting up this COM DLL. Does anyone know of a tutorial of how to make the COM DLL but doesn't give all of the extra functionality, and just explains how to pass the file and folder arguments? (If not, I'll accept jkr's comment.)
    LVL 86

    Expert Comment

    Sorry for being late here, but if you can read C++, check out the sample code that you can find on that site by clicking on the "Show Example" links (they used to have the whole code available for download via a single link earlier, but for whatever reason...)

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
    What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now