views:

1188

answers:

1

I would like to call multiple .msi files in silent mode, and halt the entire installation if any fail.

Is it possible to get the return codes of msiexec.exe being called from the [run] section?

Currently I can only see error messages in the windows event viewer.

+4  A: 

There is currently no way to check the successful execution of [Run] entries. The code just logs the process exit code and continues with the next entry (it can be examined in the Inno Setup source file Main.pas, the function is ProcessRunEntry(), starting at line 3404 in the current version 5.2.3).

If you need to make sure that multiple executions of msiexec were all successful you will need to code an intermediate layer. This can be as simple as a small stub that is executed in the [Run] entries and starts msiexec.exe with the correct parameters, waits for the process to finish, then writes the return code to a file.

Another way to check for success of such an installation step would be to add a custom procedure call for each [Run] entry by using the AfterInstall Parameter. In such a function you could for example check whether an OCX control has been successfully installed:

[Run]
Filename: "{tmp}\MyInstallation1.exe"; Parameters: "/foo"; AfterInstall: AfterMyInstallation1

[Code]
var
  MyInstallation1Success: boolean;

procedure AfterMyInstallation1;
var
  V: Variant;
begin
  try
    V := CreateOleObject('MyInstallation.InstalledOcxControl.1');
    MyInstallation1Success := True;
  except
    MyInstallation1Success := False;
  end;
end;

or whether the directories and registry entries for the dependency are all there.

Each [Run] entry is only executed when its optional Check parameter does return true. So depending on your needs you could either start all silent installations one after the other, and after the last has finished execute a script function to check that all dependencies were successfully installed; or you could write a check function for each dependency installation, which would then return false and thus skip all other installations after the first failed one.

Note however that all [Run] entries are executed after the steps for file copying, registry writing etc. are completed, so you are basically already finished with the installation. If you want to really execute all your installation steps only when all dependencies are correctly installed, then you would have to do that earlier in the process, when the installation can still be cancelled.

Edit: Check out the question "How do you make Inno Setup not look frozen while performing a long Exec?" where some information is given and a sample script is linked to about using the Exec() function for installing dependencies. So if you do not use [Run] entries there is a good chance to achieve what you want.

mghie
Thanks mghie, I think that is what I am looking for. Are there any hooks to cancel available in the run section?
Rob Hunter
Sorry, I have edited my answer to incorporate more information - it looks like you can't really do what you want using [Run] entries.
mghie

related questions