How to close .exe application on button click
Can anyone tell me how to close the .exe file on button click using C #. I have an idea how to start an .exe file on button click using C # like this:
string str = @"C:\windows\system32\notepad.exe";
process.StartInfo.FileName = str;
process.Start();
But can anyone tell me how to close the .exe application on button click in C #?
source to share
I think you want to call CloseMainWindow()
on Process
. This is similar to clicking the close button of the window, so it may not close the application.
For example, if the user edited some text in the window but did not save it, the message “Do you want to save your changes?” Appears. dialog window.
If you really want to close the application, it doesn't matter, you can use Kill()
. This may result in data loss (edits to the file will not be saved), but this may not be a problem for you.
source to share