Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Markus Raab
  Where is Markus Raab?
 Bad Kötzting
 Germany
 Markus Raab
 To: Yousfi Benameur
  Where is Yousfi Benameur?
 El Bayadh
 Algeria
 Yousfi Benameur
 Tags
Subject: RE: Control Process
Thread ID: 201250 Message ID: 201308 # Views: 30 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Win32API programming
Date: Sunday, November 02, 2008 10:19:31 AM         
   


Hello Yousfi,


the program ist running - many thanks. Now i can control and stop a process. There is a little error in your script:

If you want to kill a process:


FOR EACH loProcess IN loResult
if allt(loProcess.name)="yourexe"
loProcess.Terminate(0)
endi
NEXT


At all: many thanks, my problem is now solved.


Best Regards,


Markus






> > Hello,
> >
> >
> > in my program (let's call: MAIN.EXE) i start a second programm (let's call: second.exe) with the run command. The problem now is, that my user can start my programm (=MAIN) several times. The second program can take about 2 minutes to finish - if the user starts my program MAIN during this 2 minutes again, the second program (SECOND) will also start for a second time, third time and s.o. ....
> >
> > If i'm looking in the windows task manager, i can see the processes - how can i check, if the process SECOND.EXE is still running ?
> >
> > Many thanks
> >
> >
> > Markus
> Welcome
>
> I give you a small script who can returns you a the answer.
> put your exec name in "yourexe" (juststem only)
>
> LOCAL loWMI, lcQuery, loResult, loProcess
> loWMI = GetObject("winmgmts://")
> lcQuery = "select * from win32_process where name='"+yourexe+"'"
> loResult = loWMI.ExecQuery(m.lcQuery)
> 
> if loResult.count=0
> *well ..Run your programm run/n 
> else
> oo="Application running"
> messagebox(yourexe+" is already running !",0+32+4096,oo)
> endi
> 

>
> if you want to kill your application "yourexe" if running terminate the script above with this
>
> FOR EACH loProcess IN loResult
> if loProcess.name="yourexe"
>    loProcess.Terminate(0)
> endi	
> NEXT
> 

>
> You can also use windows API (FindWindowEx).se this News2News link where you must know the title of your window appplication.
>
> http://www.news2news.com/vfp/?function=-1&example=45
>
> You must modify it a bit for testing if your window title is in the cursor.
>
> count for  "Yout application exact title" $ wintitle to xrun
> if xrun=0
> *application not running
> else
> *application running
> endi
> 

> you can also see this link in the same subject
> http://www.ml-consult.co.uk/foxst-11.htm
> Regards
> Yousfi Benameur



COMPLETE THREAD
Control Process Posted by Markus Raab @ 11/1/2008 2:15:00 PM
RE: Control Process Posted by Frank Cazabon @ 11/1/2008 2:23:17 PM
RE: Control Process Posted by Yousfi Benameur @ 11/1/2008 2:33:51 PM
RE: Control Process Posted by Markus Raab @ 11/2/2008 10:19:31 AM
RE: Control Process Posted by Yousfi Benameur @ 11/2/2008 1:35:56 PM
RE: Control Process Posted by Carlos Alloatti @ 11/1/2008 5:14:12 PM