FabiBiu
FabiBiu

Reputation: 155

Inno Setup - how to repeat an execution of .exe file in [Run] section when it fails

Is it possible to repeat an .exe file after an termination. So when you terminate a running executable program (from Run section), because an error code appears, and then you want to execute the same program again (something like a loop).

Upvotes: 2

Views: 185

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202242

I do not think that it's possible in the Run section. Except that you may be able to do a limited number of retries, based on a non-zero exit code using cmd || operator:

[Run]
Filename: {cmd}; Parameters: "/c command params || command params || ..."

If you need better control, you should use Exec function from CurStepChanged event function in ssInstall or ssPostInstall step, like:

procedure CurStepChanged(CurStep: TSetupStep);
var
  Code: Integer;
begin
  if CurPageID = ssPostInstall then
  begin
    while (not Exec('command', 'params', '', SW_HIDE, ewWaitUntilTerminated, Code)) or
          (Code <> 0) do ;
  end;
end;

Upvotes: 2

Related Questions