I have a C# application that can be run by a argument or not. For example
- C:\MyApplication.exe
- C:\MyApplication.exe -record
Both of these instances can run at the same time. Inside another application I need to know if any instances that is started with parameter runs and if so I would like to kill them.
I tried to get it by such a code:
Process.GetProcesses().Where(x =>
x.ProcessName.StartsWith("MyApplication")
&& (x.StartInfo.Arguments == "-record"));
However StartInfo.Arguments is empty even if I set it manually when process started with the argument. How can I find my processes that started with argument?