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?
Right click on the Task bar and select Task Manager. Select his user name and then logoff.
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.
A modern day version in C# would look like this:
var processArray = Process.GetProcesses();
var process = processArray.FirstOrDefault(p => p.ProcessName == "AcroRd32");
process?.Kill();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With