I use the ShellExecuteEx function in a C ++ program to run the Uninstall.lnk file. In my program, I would like to wait for the removal to complete. My first attempt was to set the SEE_MASK_NOCLOSEPROCESS flag in the SHELLEXECUTEINFO structure, and then call WaitForSingleObject in the hProcess descriptor available in the SHELLEXECUTEINFO structure passed to ShellExecuteEx , but it still seemed to return too early.
My current suspicion is that the process launched by ShellExecuteEx (starting a new shell?) Creates new child processes but does not wait for them. Therefore, I am trying to create a "wait for my child process and all of its running children." For this I am trying to use job objects.
I created the job object using CreateJobObject , assigned the process handler returned by ShellExecuteEx to the job, and then tried to wait for the job object. Unfortunately, the assignment of the process to work failed, and I think that this is due to insufficient access rights.
Does anyone know how to set the permissions PROCESS_SET_QUOTA and PROCESS_TERMINATE (which are necessary for AssignProcessToJobObject to succeed, according to MSDN) in the process descriptor, or another way to wait for the process that ShellExecuteEx starts to complete?
UPDATE: I must indicate that I am also launching other applications, not just Uninstall.lnk . One of them, for example, is a ClickOnce , which is a simple XML file with the .application file .application .
source share