>>Yes, I read the thread already. But after I read all, I can't really follow what you are after. I just took the whole point of your thread that you are trying to make a tracker (like Spy). Eventhough maybe I had some idea but I'm not sure whether it will help or not. So I don't want to jump into the thread.
>>
>>The reason I replied into this thread is because of the title. If you only want to use ShellExecute and wait for it to finish, I have a solution for this. But as I mentioned it's *dirty*. And it won't work if the created window is hidden (need another solution)
>>
>>Yes, CreateProcess use WaitForSingleObject (WFSO) to wait and that's what I meant on the first line. What I mean is you can also use the WFSO for ShellExecute.
>>I prefer CreateProcess is because it's already provided the process handle (not provided with ShellExecute) to use in the WFSO so I consider it as *clean* method.
>>And WScript is Windows Script Host. I am sorry for my language. My english is not good :)
>>
>>Anyway, here is the detail:
>>**** dirty part
>>- Setforegroundwindow into VFP main window.
>>- ShellExecute
>>- Make a tight loop on Getforegroundwindow as long as the return handle is same with VFP main window.
>>*****
>>- Get process ID from the return window handle
>>- Open the process (synchronize) from the process ID
>>- WFSO
>>
>>HTH
>
>Herman,
>What if I have 2 instances of my vfp exe shellexecuting the same exe ? Some apps like word has only one PID. Syncing on it all VFP instances wait for all word sessions to be done, no ?
>Cetin
Yes. But since you already have the handle to the window you can add another check whether the handle still valid or not. If not then you can leave the loop in WFSO
Btw, did I misunderstand for the question on WScript ? Did you mean that WScript is just a wrapper to API ? If that's what you mean then yes you're right. It also using CreateProcess.
Herman