Such a thing: looking for the process of your application by process name (exe name, without extension)

Process[] process = Process.GetProcessesByName(processName); 

I need to then deploy it, but it does not work as it should, because finds two processes. At first I thought that this still hindered vshost, but after closing VS, it turned out that it was not. In the dispatch is shown only one process.

Why is that? And how to find exactly my process? By the name of the window does not offer.

  • That is, you started two application instances from app.exe and wonder why there are two processes by name? - Vladimir Martyanov
  • I launch one application, and at the second start I have a window that is already running. There can be no second process. - Sergey
  • One app, no question. How many times do you run something? - Vladimir Martyanov
  • How much I want, click on exe and that's it. I do not understand what this means. If I click more than two times, the process will still be 2. - Sergey
  • one
    And what is the question? Why when you run two instances you have two processes? - Vladimir Martyanov

1 answer 1

Sergey, judging by the expressions

I need to then deploy it ...

on the second launch, I have a window that is already running ...

How much I want, click on exe and everything ...

It seems that you need one copy of the application.
If I understand correctly, why not use a ready-made solution? Like this , or search for "Single Instance Application". There is a dozen worthy solutions on one "stackoverflow.com".

If you have another task, add more details to your question. Because, on the move it is not clear what exactly you are trying to solve.

PS Unfortunately not enough points to comment, forced to write a comment as an answer.