You can use GetExitCodeProcess
] and check for STILL_ACTIVE (259) to see if the process is still running or not.
A better method than polling for process completion, I think, would be to create the process with CreateProcess
], then use WaitForSingleObject on the process handle to know exactly when the process exits.
Two reasons this is a better method:
1. "setup.exe" may or may not refer to the "setup.exe" you started. There may be more than one instance.
2. polling is a waste of processor resources, WFSO is a more efficient and elegant solution.