Closing one application from another in C # .net

I am working on a C # project. From my application, I need to close another application (both are my own applications). Can I get an instance of the first application in the second?

+5
source share
4 answers

you need to get the whole process in an array of processes so that we get a process that is running

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 a different process, or you can say that the application on which we are going to kill

+12
source

# :

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

, namedpipes

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

+1
source

All Articles