Page 1 of 1

Test and kill external application

Posted: Mon Jun 15, 2015 6:39 am
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.

Re: Test and kill external application

Posted: Mon Jun 15, 2015 7:06 am
by rdonnay
RunShell( '/IM Notepad.exe', 'TaskKill.Exe' )

Re: Test and kill external application

Posted: Mon Jun 15, 2015 8:25 am
by unixkd
How can one check if exe is running

Thanks.

Joe

Re: Test and kill external application

Posted: Mon Jun 15, 2015 8:51 am
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. ;)

Re: Test and kill external application

Posted: Mon Jun 15, 2015 9:01 am
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

Re: Test and kill external application

Posted: Mon Jun 15, 2015 9:39 am
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 838 times