How to kill a process

Post Reply
User avatar
Rafael Clemente
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

How to kill a process

Post by Rafael Clemente »

Upon starting an application, I would like to be able to kill a certain process or app that shows in the Task Manager as FtLnSOP.exe. Manually, I can do it by right clicking it and asking "Kill the process tree". Is there any way of achieving the same from the program?
Thanks
Rafael
User avatar
wmormar
Posts: 1050
Joined: Fri Oct 07, 2005 10:41 pm
Location: México
Contact:

Re: How to kill a process

Post by wmormar »

Rafael Clemente wrote:Upon starting an application, I would like to be able to kill a certain process or app that shows in the Task Manager as FtLnSOP.exe. Manually, I can do it by right clicking it and asking "Kill the process tree". Is there any way of achieving the same from the program?
Thanks
Rafael
Este link te puede servir

Utilizando wmi, se pueden hacer muchas cosillas

Saludos
William, Morales
Saludos

méxico.sureste
Frank Demont
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Post by Frank Demont »

Rafael

Here you have an example.

In this example shellexecute starts wordpad with efkes.rtf. The use has to close this aplication first before continuing. If this not occured , the program will do that.

Code: Select all

Shellexecute(0 ,0  , "C:\TEMP\efkes.rtf" ,0 ,0 , 1)          
hWnd := FINDWND( "EFKES.RTF" ) 
			
? "Atention , wordpad must be closed correctly"
      
DO WHIL .T.
    hWnd := FINDWND( "EFKES.RTF" ) 

    IF ! EMPTY( hWnd ) 
       ? "the aplication closes Winword"  
        SENDMESSAGE( hWnd, 16 ) 
    End
END
Frank Demont
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Missing FindWnd()

Post by Frank Demont »

Code: Select all

// from http://fivetechsoft.com/forums/viewtopic.php?t=1346&start=0&postdays=0&postorder=asc&highlight=findwindow%2A 
#define GW_HWNDFIRST 0 
#define GW_HWNDLAST  1 
#define GW_HWNDNEXT  2 
#define GW_HWNDPREV  3 
#define GW_OWNER     4 
#define GW_CHILD     5 

FUNCTION FINDWND( cTitle ) 

LOCAL hWnd := GETWINDOW( GETDESKTOPWINDOW(), GW_CHILD ) 

WHILE hWnd != 0 
    IF UPPER( cTitle ) $ UPPER( GETWINDOWTEXT( hWnd ) ) 
        RETURN hWnd 
    ENDIF 

    hWnd = GETWINDOW( hWnd, GW_HWNDNEXT ) 
ENDDO 

RETURN NIL 
User avatar
Rafael Clemente
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Post by Rafael Clemente »

Frank:

Thank you for your suggestion. The problem is that I do not know the Window title of the program to kill; only its name as it appears in the Task Manager, i.e: "FtLnSOP.exe"

Any other suggestion? _'s sollution seems promising, but at present I have been unabe to compile his example (see Spanish Forum).

Regards,

Rafael
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Rafael,

You may use TerminateProcess()

http://support.microsoft.com/default.as ... -us;178893&
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

If I must terminate many processes but I not Know how many application are in process, but only these processes not mine program ...
How I can make it ?

Can I have an small sample,pls ?
Best Regards, Saludos

Falconi Silvio
User avatar
Rafael Clemente
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Post by Rafael Clemente »

Same for me, pls

Rafael
User avatar
Rafael Clemente
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Post by Rafael Clemente »

_:
Muchííííísimas gracias. Funciona perfecto. Es justo lo que yo necesitaba
Un saludo
Rafael
Post Reply