|
-
Jan 2nd, 2010, 08:14 PM
#1
Thread Starter
Frenzied Member
How to End process in vb.net
For example "C:\myapp\app.exe"
I know this code Process.Start("C:\myapp\app.exe") but this only starts the file and does not end it. How can i end it thank you in advance
-
Jan 2nd, 2010, 08:42 PM
#2
Re: How to End process in vb.net
Process.Kill works but this is a bad way to close an application.
-
Jan 2nd, 2010, 08:54 PM
#3
Re: How to End process in vb.net
 Originally Posted by Pc_Not_Mac
For example "C:\myapp\app.exe"
I know this code Process.Start("C:\myapp\app.exe") but this only starts the file and does not end it. How can i end it thank you in advance 
Again, this is one of those situations that all you needed to do was utilize Google.
You'll always want to try CloseMainWindow first and then call .Kill so that it's only done if needed.
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Jan 2nd, 2010, 10:52 PM
#4
Hyperactive Member
Re: How to End process in vb.net
Code:
For Each p As Process In Process.GetProcessesByName("app")
p.Kill()
Next
-
Jan 2nd, 2010, 11:07 PM
#5
Re: How to End process in vb.net
What Philly0494 means is:
VB.NET Code:
For Each p As Process In Process.GetProcessesByName("app") If p Is Nothing Then Return If Not p.CloseMainWindow() Then p.Kill() Next
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Jan 3rd, 2010, 12:00 AM
#6
Re: How to End process in vb.net
isn't CloseMainWindow redundant? Or it leaks?
-
Jan 3rd, 2010, 12:41 AM
#7
Re: How to End process in vb.net
 Originally Posted by cicatrix
isn't CloseMainWindow redundant? Or it leaks?
I'm not sure what you're asking exactly.
But the reason you'd send CloseMainWindow first, is because .Kill could cause issues.
Kill:
 Originally Posted by MSDN
Immediately stops the associated process.
If that process is in the middle of doing something important, you could cause additional problems and so it should be a last resort.
CloseMainWindow:
 Originally Posted by MSDN
Closes a process that has a user interface by sending a close message to its main window.
By sending a message to the application, it has the opportunity to stop or do whatever it needs to, to make sure everything else continues to run smoothly.
Now, I could be terribly wrong, but that's what I've inferred from the documentation and what I've read around VBF.
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|