0

I know the title is alittle confusing but I have a problem with getting a certain process that gets created by a process I start in my code and here is what I mean ..

private void BtnUNINSTALLG_Click(object sender, EventArgs e)
    {
        LoadingGif1.Visible = true;
        Process p = Process.Start(@"C:\program files\XXXX\XXXX\XXX\XXXX.exe");
        p.EnableRaisingEvents = true;
        p.Exited += new EventHandler(UNINSTALL_Exited);
    }
    private void UNINSTALL_Exited(object sender, System.EventArgs e)
    {
        Invoke(new Action(() => {
            LoadingGif1.Visible = false;
            DoneGif1.Visible = true;
        }));

    }

What I do here is I start a process and after it exits I do some stuff .. but that doesn't work because this process create temp.exe ( changes name every time ) in temp folder and the process I started exits right after this temp process created.

I want to get the temp process created by the process I started and then wait until it exits instead of the process I started. Does anyone have any idea how can I do that ?

Ahmed Rizk
  • 11
  • 2
  • Here is another question which may help you. Try to monitor newly created processes and look for your temp.exe https://stackoverflow.com/questions/972039/is-there-a-system-event-when-processes-are-created – Michael Navara Dec 21 '21 at 13:19
  • You could also try and use `ManagementObjectSearcher` to locate the child process of the process you started, [more info here](https://stackoverflow.com/questions/17922725/monitor-child-processes-of-a-process/38614443) – Lennart Stoop Dec 21 '21 at 13:30
  • unfortunatly it's not a child process it's just a new process started by the original process and then the original process just exits. – Ahmed Rizk Dec 21 '21 at 15:01

0 Answers0