title: How can I wait until an external process has completed?
body: <p>So I have made a form in Delphi that allows me to run various sikuli scripts with various configurations. What I am working on now is to make it possible for someone using the form, to set up various sikuli scripts to run on after another. As in: </p>
  
  <p>Step 1: SikuliScript1 with ConfigFile1.
  Step 2: SikuliScript2 with ConfigFile2.
  etc...
  This is my code so far:</p>
  
  <pre><code>procedure TSikRunForm.btnRunClick(Sender: TObject);
  begin
      DirCombo:= '/C '+DirSik+'\sikuli-script.cmd' +' -r ' + DirScript + ' --args '+DirConfig;
      if SikFound then begin
        ShellExecute(Handle, nil, 'cmd.exe', pChar(DirCombo), nil, SW_SHOWNORMAL);
        Application.minimize;
      end else begin
        ShowMessage('Select the correct folder for your Sikuli installation folder');
      end;
  end;
  </code></pre>
  
  <p>And this works perfect, the sikuli script runs perfectly, and while running, the cmd line is visible with the various actions shown that are being performed. After the sikuli script is done, the cmd line closes on its own. So the shell handler knows when to shut down the running process. So my question is: Is it possible to tell delphi: After the handler has shut the process, run the next process (Sikuli Script)?
  Now I know I can go with the whole createProcess in delphi, but it just seems overkill. There has got to be a way to do this faster and easier. 
  Anyone have a clue?</p>