Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7073685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:57:32+00:00 2026-05-28T05:57:32+00:00

I posted another question earlier about getting the arguments from a context menu App.

  • 0

I posted another question earlier about getting the arguments from a context menu App. If you select an item it gives you the string path to that item, but it starts a new instance of the app for every item selected greater than one. With Environment.GetCommandLineArgs() it gives you a string array with the first element is the .exe calling the function and the second element being the string path of the item selected. Again, If I select 2 or more items and right-click >> run app, I get 2 or more instances of the app, each with the first element as the .exe followed by the second element as one of the items selected. (I did this with MessageBox.Show() after joining the two elements and it pops up the message box 3 times, 1 for each of the three items selected).

Now I am using Mutex to only allow it to run once but I only get the first message box (as expected).

How can I get all the items listed in one instance if I select more than one Item?

Here is the code without mutex:

static void Main()
    {
        String[] args = Environment.GetCommandLineArgs();
        var message = string.Join(", ", args);
        MessageBox.Show(message);
    }

And here it is with Mutex:

static void Main()
    {
        Mutex startOnlyOne = new Mutex(false, "WinSyncSingalInstanceMutx");
        if (startOnlyOne.WaitOne(0, false))
        {
            String[] args = Environment.GetCommandLineArgs();
            var message = string.Join(", ", args);
            MessageBox.Show(message);
            startOnlyOne.Close();
        }

No one has been able to help me out with this yet, I hope someone can help me figure this out. Thanks in advance…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:57:33+00:00Added an answer on May 28, 2026 at 5:57 am

    You need an external process to handle this, with your shell extension merely being the “trigger” mechanism. Don’t try to keep the shell extension itself as a single instance app.

    Instead, you can create a service which listens for incoming events from your extension, perhaps via WCF. Then it can do whatever you need with the incoming file paths.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following on from a question I posted yesterday about GUIs, I have another problem
I had posted another question earlier about deployment with Passenger. That problem turned out
I'm working from a question I posted earlier ( here ), and trying to
I'm making a visualization for a BST implementation (I posted another question about it
I posted another question about the Roberts operator, but I decided to post a
I have already posted another question about this, but no one seemed to know
this might seem like a weird question, earlier I posted another question on ASP
This question is related to another question that I posted on SO earlier How
i posted another question about this, but i think this one will be more
In another question , David Heffernan posted a comment about his all time least

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.