Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

kill application in systems' application

Status
Not open for further replies.

bont

Programmer
Sep 7, 2000
200
US
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.

Hope it helps
Cheers
Manish

(2)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top