Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Closing one application from another in c# .net [closed]

Tags:

c#

I am working on a c# project. From my application i have to close another application (Both are my own applications). Can i get the instance of first application in the second?

like image 264
Hali Avatar asked Sep 22 '10 09:09

Hali


People also ask

How do I close an app from another user?

Right click on the Task bar and select Task Manager. Select his user name and then logoff.

How do I close a specific application in C#?

You can use the methods Process. Kill or Process. CloseMainWindow to stop a process. If the app has no GUI then just call Kill, otherwise a well-designed GUI application should respond to the CloseMainWindow method and allow the user to save his work before the application closes.


1 Answers

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

var processArray = Process.GetProcesses();
var process = processArray.FirstOrDefault(p => p.ProcessName == "AcroRd32");
process?.Kill();
like image 103
alan Avatar answered Oct 13 '22 10:10

alan