By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,035 Members | 1,555 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,035 IT Pros & Developers. It's quick & easy.

How can I close a running program like the Task Manager does?

P: 10
I am trying to figure out the coding that on a button click it will close a specified program nicely similar to the Task Manager's "End Process." This is because sometimes when I close a program it still remains running in the task manager. I have done some research before hand into this and one method I found that was suggested was by using WM_CLOSE. However, I can't seem to get it to work as I am taking pieces of coding from several sources to help create the effect I want (which I try to avoid but when faced with a completely new concept of coding to understand this is the only way I know how.)

Any help to explain how to use this code properly, with an example, would be greatly appreciated or any other more efficient technique you would suggest would be amazing.

{I am currently using Microsoft Visual Basics 2010 Express to create my programs}
Sep 5 '14 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,208
If you close the form and its still running in task manager, that means that there is a thread still running. Killing the process is a sloppy fix to the issue.
But if you really must do it this way you can use system.diagnostics.process, iterate the processes or get the process by name then use the .kill method.
Oct 5 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.