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