title: How to use exec with parameter to interact with running process being extracted
body: <p>Salve!  Well, I have scoured the web (and Stack Overflow) for an answer.  I need help getting my Inno installer to send a commandline with parameters to a running application.</p>
  
  <p>In myapplication_setup.exe I have packed myapplication.exe.  Now, myapplication.exe is equipped with the ability to receive commandline parameters.  If I launch a second instance with certain parameters, it will pass them to the first instance and then exit its own second instance (both are exited).  This lets me use the second instance of myapplication.exe to make the first instance exit.  This part works perfectly if I do it from a batch file or cmd box or run box.</p>
  
  <p>Now, I need the installer to call this commandline:  "c:\myapplication\myapplication.exe quit" and then check to see if both instances have exited.  I might be able to get away with just checking for the second instance that the installer has launched, because they both exit at about the same time.  I don't know inno so well, so here is the code I have come up with to do the commandline function.  Problem is that I always get the ResultCode of 267 and myapplication has never exited.</p>
  
  <p>The setup program needs to call the exec function and make sure myapplication.exe has exited before it extracts the new version of myapplication.exe.  </p>
  
  <p>Could someone look over my code and help me out?  Thanks!</p>
  
  <pre><code>[code]
  function PrepareToInstall(var NeedsRestart: Boolean): String;
  var
    ResultCode:   Integer;
  begin
     if Exec('C:\myapplication\myapplication.exe', 'quit', '{app}', SW_HIDE, ewWaitUntilTerminated, ResultCode) then
     begin
        msgbox('True: C:\myapplication\myapplication.exe : ' + IntToStr(ResultCode), mbInformation, MB_OK);
     end
     else begin
        msgbox('False: C:\myapplication\myapplication.exe : ' + IntToStr(ResultCode), mbInformation, MB_OK);
        SysErrorMessage(ResultCode)
     end;
  end;
  </code></pre>