473,408 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Stopping a program run from another

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
Jul 6 '07 #1
6 1443
On Jul 6, 7:55 am, "Ed Bitzer" <edbit...@yahoo.comwrote:
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

Jul 6 '07 #2
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
"Ed Bitzer" <ed******@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
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

Jul 6 '07 #3
On Jul 6, 9:17 am, Chris Dunaway <dunaw...@gmail.comwrote:
On Jul 6, 7:55 am, "Ed Bitzer" <edbit...@yahoo.comwrote:
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
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

Jul 6 '07 #4
You probably would do the suggestions above within the main form closing
handler.

"Ed Bitzer" wrote:
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
Jul 6 '07 #5

"Ed Bitzer" <ed******@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
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


Jul 7 '07 #6
On Fri, 6 Jul 2007 08:55:24 -0400, "Ed Bitzer" <ed******@yahoo.com>
wrote:
>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?

--
http://bytes.thinkersroom.com
Jul 7 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: BKM | last post by:
I'm using a VB6 WebBrowser control to get info from various web pages and, occasionally, my program stops when it finds a script error on the page. It won't resume until I click 'Yes' or 'No' on...
3
by: Tobias Pfeiffer | last post by:
Hi! I am writing a network game where the server runs in a console window. The person who has opened the server shall be able to stop the process of accepting new clients. By now, I am handling...
7
by: python | last post by:
I have a script that downloads some webpages.The problem is that, sometimes, after I download few pages the script hangs( stops). (But sometimes it finishes in an excellent way ( to the end) and...
3
by: VB Programmer | last post by:
Is aspnet_wp a service that can be stopped/restarted? Or, do I have to kill it through Task Mgr? If so, how do I restart it? Thanks.
4
by: bjm | last post by:
I am writing a program that will automate a series of application installations. I want to give the user the option of stopping the program's execution in between installations (for example, give...
4
by: Jeff | last post by:
Hi, I'd like to write Javascript that stops animated gifs from animating. On Firefox, at least, window.stop(); does the trick, although it stops everything on the page and is kind of...
2
daniel aristidou
by: daniel aristidou | last post by:
Hi i wrote code to print records off a datagrid.the code works on all but one of my data grids. The problem is that loop continues without stopping, Causing the program to crash. The only diff...
4
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, i have a main thread an another worker thread. The main Thread creates another thread and waits for the threads signal to continue the main thread. Everything works inside a ModalDialog and...
2
by: Steve | last post by:
Hi All, I've been trying to come up with a good way to run a certain process at a timed interval (say every 5 mins) using the SLEEP command and a semaphore flag. The basic thread loop was always...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.