Question: Is it possible to wait for all processes launched by a child process in Windows? I can't modify the child or grandchild processes.

Specifically, here's what I want to do. My process launches uninstallA.exe. The process uninistallA.exe launches uninstallB.exe and immediately exits, and uninstallB.exe runs for a while. I'd like to wait for uninstallB.exe to exit so that I can know when the uninstall is finished.

Answer: 
Create a Job Object with `CreateJobObject`. Use `CreateProcess` to start `UninstallA.exe` in a suspended state. Assign that new process to your job object with `AssignProcessToJobObject`. Start UninstallA.exe running by calling `ResumeThread` on the handle of the thread you got back from `CreateProcess`.

Then the hard part: wait for the job object to complete its execution. Unfortunately, this is quite a bit more complex than anybody would reasonably hope for. The basic idea is that you create an I/O completion port, then you create the object object, associate it with the I/O completion port, and finally wait on the I/O completion port (getting its status with `GetQueuedCompletionStatus`). Raymond Chen has a demonstration (and explanation of how this came about) on his [blog](https://devblogs.microsoft.com/oldnewthing/20130405-00/?p=4743).
Use a [named mutex](http://msdn.microsoft.com/en-us/library/ms682411(VS.85).aspx).