Stopping a program run from another

  • Thread starter Thread starter Ed Bitzer
  • Start date Start date
E

Ed Bitzer

You have taught me how to start another program using
System.Diagnostics.Process.Start and suggested a good tip site and
Google search for future reference. My problem now is how to stop
that program I started. Even if I close my main program this program
remains listed in the Task Manager. I promise you I searched but
using words like end, stop, close found me lots of information but not
my specific need. Appreciate if you would help again

Ed
 
You have taught me how to start another program using
System.Diagnostics.Process.Start and suggested a good tip site and
Google search for future reference. My problem now is how to stop
that program I started. Even if I close my main program this program
remains listed in the Task Manager. I promise you I searched but
using words like end, stop, close found me lots of information but not
my specific need. Appreciate if you would help again

Ed

Have you looked at the docs for the Process class? You might try
Process.CloseMainWindow or Process.Close.

Good luck

Chris
 
Something like this you are looking for ?

Private Sub KillExcel()

Dim myProcesses As Process
Dim myProcess As Process

myProcesses = Process.GetProcessesByName("EXCEL.EXE")
For Each myProcess In myProcesses
myProcess.Kill()
Next

myProcesses = Nothing
myProcess = Nothing

End Sub

Miro
 
Have you looked at the docs for the Process class? You might try
Process.CloseMainWindow or Process.Close.

Good luck

Chris

What Chris means:

Dim pi As New ProcessStartInfo("MyDialer.exe", "123 456 1234")
Dim p As Process = Process.Start(pi)
'// I also find a System.Threading.Thread.Sleep(...) is sometimes
'// needed to allow the app to receive the close messages
p.CloseMainWindow
p.Close

Thanks,

Seth Rowe
 
Ed Bitzer said:
You have taught me how to start another program using
System.Diagnostics.Process.Start and suggested a good tip site and
Google search for future reference. My problem now is how to stop
that program I started. Even if I close my main program this
program remains listed in the Task Manager. I promise you I
searched but using words like end, stop, close found me lots of
information but not my specific need. Appreciate if you would help
again

Ed

Here is the code I finally settled upon inserted in the Form.Closed
sub - I will try the other ideas suggested to gain some better
understanding.
For Each oProcess2 In System.Diagnostics.Process.GetProcesses()
If oProcess2.ProcessName.ToString = "phonepro" Then
oProcess2.Kill()
MessageBox.Show("Process started from code is now
killed")
Exit For
End If
Next
Application.Exit() '

Ed
 
You have taught me how to start another program using
System.Diagnostics.Process.Start and suggested a good tip site and
Google search for future reference. My problem now is how to stop
that program I started. Even if I close my main program this program
remains listed in the Task Manager. I promise you I searched but
using words like end, stop, close found me lots of information but not
my specific need. Appreciate if you would help again

Ed

Perhaps you should first figure out why the called program does not
close cleanly ... is it supposed to terminate itself when it has
completed its operation?
 
Back
Top