Wait for a process to end


I have an app that uses startAsProcess to launch an EXE. I’d like to wait for that EXE to finish doing its thing then display a log from it. The amount of time the EXE takes to finish is arbitrary. It doesn’t look like there’s anything that would give me a process handle when I launch the EXE, and nothing that would be able to tell me when it’s finished. I don’t see any InterprocessConnection stuff that would help, either.

I might be able to use File::getLastModificationTime on one of the two files the EXE creates, as long as the files are only written when the process exits (not sure), but I was hoping there was a more normal way to see when the process ended.



InterprocessConnection has a connectionLost callback.

If you’re providing the EXE you’re running then you can make it connect back to your app. When it stops you’ll get the callback.



The EXE is not an app I designed and not something I can rewrite using JUCE.


If you are out for a quick hack on Windows, you could start the external app through a Windows shell script.

The script can monitor the status of the process and write a file or use some other mechanism to signal your Juce app that the process has ended.

For Windows Script Host docs you may start here:

Alternatively you could use _spawnl(…) to start the process instead of ShellExecute which is a real high level function that does not return a process handle.
For docs on the C-Runtime lib function _spawnl(…) see

Good luck


while I don’t know the method off the top of my head, you should be able to retrieve the handle of a running process, and with the handle use something like WaitForSingleObject to block until the process exits.