Closing one application from another in c# .net

you have to get all the process in the process array so that we will get which process is going on

Process []GetPArry = Process.GetProcesses();
foreach(Process testProcess in GetPArry)
{
    string ProcessName = testProcess .ProcessName;

    ProcessName  = ProcessName .ToLower();
    if (ProcessName.CompareTo("winword") == 0)
        testProcess.Kill();
} 

here winword is the another process or you can say application running whom we are going to kill


A modern day version in C# would look like this:

var processArray = Process.GetProcesses();
var process = processArray.FirstOrDefault(p => p.ProcessName == "AcroRd32");
process?.Kill();

this can be done by using namedpipes

1- Use NamedPipe to send some event to close the second instance.

Tags:

C#