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 :wave:
Printable View
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 :wave:
Process.Kill works but this is a bad way to close an application.
Code:For Each p As Process In Process.GetProcessesByName("app")
p.Kill()
Next
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
;)
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:
If that process is in the middle of doing something important, you could cause additional problems and so it should be a last resort.Quote:
Originally Posted by MSDN
CloseMainWindow:
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.Quote:
Originally Posted by MSDN
Now, I could be terribly wrong, but that's what I've inferred from the documentation and what I've read around VBF.