How to kill a process

How to kill a process

Postby Rafael Clemente » Thu Aug 31, 2006 8:01 pm

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
Rafael Clemente
 
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Re: How to kill a process

Postby wmormar » Fri Sep 01, 2006 3:51 am

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
User avatar
wmormar
 
Posts: 1074
Joined: Fri Oct 07, 2005 10:41 pm
Location: México

Postby Frank Demont » Fri Sep 01, 2006 8:37 am

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  Expand view  RUN
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()

Postby Frank Demont » Fri Sep 01, 2006 11:32 am

Code: Select all  Expand view  RUN
// 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
Frank Demont
 
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Postby Rafael Clemente » Fri Sep 01, 2006 11:43 am

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
Rafael Clemente
 
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Postby Antonio Linares » Fri Sep 01, 2006 12:39 pm

Rafael,

You may use TerminateProcess()

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42120
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Silvio » Sat Sep 02, 2006 7:09 pm

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
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby Rafael Clemente » Sat Sep 02, 2006 10:18 pm

Same for me, pls

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

Postby Rafael Clemente » Sun Sep 03, 2006 8:12 am

_:
Muchííííísimas gracias. Funciona perfecto. Es justo lo que yo necesitaba
Un saludo
Rafael
User avatar
Rafael Clemente
 
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 82 guests