2
votes

I'm preparing an inno setup to install a windows forms application and an office add-in both at the same time. I deploy all my windows forms files (exe and dll) and the office add-in deployment files during installation and all works fine. But at the end, I got the "installation finished" screen while the office addin "setup.exe" is still running. I don't care about seeing the other installed running or popup in the background, but I don't like the inno setup says "finished" while the other application is running.

This is my code:

[Run]
Filename: "{app}\AddIn\Deploy\setup.exe"; Flags: waituntilterminated runminimized 
Filename: "{app}\MyApp.exe"; Description: {cm:LaunchProgram,{cm:MyAppName}}; Flags: nowait postinstall 

So, it doesn't obey "runminimized", which I'm fine anyway.... but it doesn't obey "waituntilterminated" either, which I do care.

Note that "AddIn\Deploy\setup.exe" is the file generated by Visual Studio by the "Publish" wizard of the office add-in.

I'd be happy if I only could run this code:

[code]
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
  ResultCode : Integer;
begin

  if Exec(ExpandConstant('{app}\AddIn\Deploy\setup.exe'), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
  begin
    Result := 'AddIn Installed';
  end
  else 
    Result := 'AddIn NOT Installed';

  NeedsRestart := false;
end;

But, I would have to running right after the main inno installer copied the files to the "AddIn\Deploy" directory... So, I might just need the right event to override.

1
You can create the folder and extract that file manually, but it's quite overkill. What about immediately after installation succeed, in CurStepChanged event when the CurStep will be ssPostInstall ?TLama
@TLama I tried your suggestion but I have the same effect the "Finish" dialog is always shown while the add-in setup is still running.Craig Stevensson
Then the add-in setup must create a separate process and exit itself. The waituntilterminated flag in [Run] section works also as expected. You can test both cases simply by executing e.g. notepad.exe. You will see that the finish page will not be displayed until you close that notepad instance.TLama
Just verified. The installer generated by VS behaves somehow asynochronous, and the setup process you initially execute immediately exits. I've checked the publish options for the project, but I cannot find anything what might switch the VS generated installer to some synchronous mode. I'm using VS 2012, but only the Express edition, where this can be limited.TLama
I think it is really not related to an asynchronous mode per-se. What is happening is that the "setup.exe" generated by the Publish option in VS, just calls the "addin.vsto" file, which is the actual installer. So, setup.exe begins and ends very quickly, but it is the other process lunched by it which keeps running.Craig Stevensson

1 Answers

3
votes

The code you submitted could be enhanced to:

    [code]
    function PrepareToInstall(var NeedsRestart: Boolean): String;
    var
     ResultCode : Integer;
    begin
     // Your original line: 
     // if Exec(ExpandConstant('{app}\AddIn\Deploy\setup.exe'), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
     if Exec(AddQuotes(ExpandConstant('{app}\AddIn\Deploy\setup.exe')), AddQuotes(ExpandConstant('{app}\AddIn\Deploy\')), '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
      begin
       Result := 'AddIn Installed';
      end
     else
      begin // <== 
       Result := 'AddIn NOT Installed';
      end; // <==
     NeedsRestart := false;
    end;

The {app} may contain spaces and the function AddQuotes does create Quotes around a string if the string contains spaces The exec function, in my opinion, acts like a shortcut, so give the application a workingdir. Because I do not know the nature of your Setup.exe, I gave this application as workingdir the same folder as where the application resides.

A bit off-topic note: Use SW_Hide in the final version. The result if the application has installed the addin can always be seen if other modes are chosen other than SW_HIDE :)