Test and kill external application

Xbase++ 2.0 Build 554 or later
Post Reply
Message
Author
Victorio
Posts: 621
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Test and kill external application

#1 Post by Victorio »

How can I test, if other application is running and how can I kill this ?
For example I want run other exe program notepad.exe, and first I want test, if it is running. If yes, nothing happens, if no, notepad.exe run
And then I want kill this program from Xbase++ application.

Data is no problem, because external application is in view mode, and no data change in it.

I examine some example from here, xbwin,but I do not know,how compile, some error
I tried ot4xb, download ot4xb.lib and ot4xb.ch, link but error :
unresolved external symbol _CALLBACK_WILDFINDWINDOW_ENUMPROC,
I do not know, what is it.

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Test and kill external application

#2 Post by rdonnay »

RunShell( '/IM Notepad.exe', 'TaskKill.Exe' )
The eXpress train is coming - and it has more cars.

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: Test and kill external application

#3 Post by unixkd »

How can one check if exe is running

Thanks.

Joe

Victorio
Posts: 621
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: Test and kill external application

#4 Post by Victorio »

ok, I found taskkill, it runs ok,
also for view if exe is running is "command" tasklist for ezxample :
tasklist /fi "imagename eq notepad.exe"
this generate listing where is info, if this process is running. I want use this report (generate to file >file.txt ) and read this file
but better will be some command : isrunning("notepad.exe") .T. or .F. ;)

User avatar
Tom
Posts: 1171
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Test and kill external application

#5 Post by Tom »

Hi, Victorio.

Look at this message from the "German Xbase Forum". It shows you how to get an array with all running tasks in it:

http://www.xbaseforum.de/viewtopic.php? ... ist#p92485
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

Re: Test and kill external application

#6 Post by Auge_Ohr »

Victorio wrote:How can I test, if other application is running and how can I kill this ?
if you "run" a external Application with RunShell() you have "no Control" about it ... it might "run" or "hang" ...
you need a Handle to check "IsRunning" or to "kill" a Task.

Rogers Solution will IHMO "kill all" Notepad.EXE Tasks when have more than 1 Instance.
try Pablos TRunProcess Class to "run" a external Application
TRunProcess.zip
need ot4xb.DLL
(3.95 KiB) Downloaded 797 times
greetings by OHR
Jimmy

Post Reply