Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WaitForSingleObject and setup.exe ????

Status
Not open for further replies.

ipazzo

Programmer
Jan 17, 2002
69
IT
Hi All,
I'm want to execute a setup program from my FOX application. I use the
CreateProcess API function and WaitForSingleObject WIN API function to
accomplish this. When I execute notepad.exe, the WaitForSingleObject
function waits untill I close the notepad. But when I'm executing the
required exe(the command line is "E:\INSTALL\WIN32\setup.exe")
the WaitForSingleObject function is not waiting for the setup to finish or
exit.
Please helpme with this.

Thanks
 
Hi

WaitForSingleObject (WFSO) doesn't have to wait for the process to finish. Just look for the API name we can tell that it waits for a single (whatever) object/signaled

I've never get the situation like you, but maybe Setup.exe is signaling something (other than exit) to the calling process. So you need to trap that signaled.

Use GetExitCodeProcess for that, and check if the exitcode is equal to STILL_ACTIVE, loop to WFSO again

Hope it helps

-- AirCon --
 
Ipazzo,

I'm not sure if this will help, but, as an alternative to using those API functions, the Windows Scripting Host has a Run method which can optionally wait until the target application has closed.

Here is the code:

oWsh = CREATEOBJECT("wscript.shell")
oWsh.Run("Notepad",1,.T.)

The second parameter to Run is the window state. The third param is .T. if you want the caller to wait until the called program has closed.

Mike


Mike Lewis
Edinburgh, Scotland
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top