What would be the best way to see if an application is running in the OS system (Win 2000 / XP) and to kill it before starting another instance of it using a shell command? All of this from within a VB 6.0 app.
I would n't remember it completely now. There are two ways that I had tried. May not be the best, but worked.
(1) There is an exe called "Kill.exe" available from Micorosoft. Just pass the Process ID (available in the Task Manager) or the Window Text (Form.Caption) , and that process will be killed.
e.g. To kill a VB application that running and had a Form.Caption "Hello App", use the shell command to execute Kill "Hello App" and the process is killed.
You could also use FindWindow() API and then get the Process ID of the application and then call the Kill.exe.
(2) Second way, is use the Windows Mangement Instrumentation(WMI - WBEM) and you can query the objects to retrieve all the Processes running in the local machine and then kill the chosen one.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.