Alex
Alex

Reputation: 2609

How to make Inno Setup installer keep temporary files either after installation completes or after VSTO installer completes?

I have Inno Setup installer (written before me) which extracts a set of VSTO files and starts VSTO MS Office addin installation then. It has a problem that upon extracting VSTO files into a temp folder and launching VSTOInstaller.exe it immediately displays Finish button. If the user clicks it, temporary files are deleted and starting the actual installation of VSTO addin in VSTOInstaller then results in "file not found" errors. I'm supposed to fix that (ideally, to have Finish button in Inno Setup installer appear only when VSTOInstaller spawned by it has finished execution).

VSTO package itself (a collection of "Application Files" folder, setup.exe and .vsto file) is created by ClickOnce Publish tool in Visual Studio. The package is digitally signed, etc.

I tried various options:

Currently .iss file looks like:

;---------------------------------------------------------------------
[Setup]
AppName=Outlook Addin
AppVerName=Outlook Addin 2.0
DefaultDirName={tmp}
DefaultGroupName=Outlook Sync Addin
Compression=bzip
Uninstallable=no
OutputBaseFilename=OutlookSetup
VersionInfoVersion=2.0.0.10
UsePreviousAppDir=no
;
;---------------------------------------------------------------------
[Files]
Source: "SourcesForExe\*"; DestDir: "{app}"; Attribs: hidden system; Flags: recursesubdirs uninsneveruninstall
;---------------------------------------------------------------------
[Run]
Filename: "{app}\OutlookAddin.vsto"; Parameters: "OVERRIDE=YES"; StatusMsg: "Extracting Outlook Addin installer..."; Flags: shellexec waituntilterminated

Originally, the installer run setup.exe rather than OutlookAddin.vsto. This caused setup.exe to launch VSTOInstaller.exe and immediately shut down. I thought changing to OutlookAddin.vsto (and adding shellexec flag) would fix that so that VSTOInstaller.exe would be launched directly by this method but but it didn't work. Turns out .vsto files are opened by vstoee.dll first.

Any idea how to either keep unpacked files (it's not a big deal that they will stay in temp folder) or somehow wait for all child processes spawned during the setup process?

If that matters, Inno Setup is 5.2.3, VSTO is built with Visual Studio 2015. Tested with Outlook 2010 and 2016.

Upvotes: 1

Views: 1647

Answers (2)

Martin Prikryl
Martin Prikryl

Reputation: 202474

{tmp} is setup's temporary folder, which gets deleted at the end. If you want to preserve the files, explicitly refer to the user's temporary folder using TEMP environment variable:

DefaultDirName={%TEMP}\outlook_addin_tmp

Though, it is a hack – the correct solution would be to wait for the VSTO installer to finish. I suggest you start the VSTOInstaller.exe explicitly. It should allow you to wait for it to complete

Something like this:

Filename: "{commonpf}\microsoft shared\VSTO\<ver>\VSTOInstaller.exe"; \
  Params: "{app}\OutlookAddin.vsto"; \
  StatusMsg: "Extracting Outlook Addin installer..."; Flags: waituntilterminated

Upvotes: 4

Saad Ghani
Saad Ghani

Reputation: 9

I recently created this same as u required. It is working fine for me, Start setup.exe then searches for VSTO process and binds exit event to it.

            var process = Process.Start("Setup.exe");
            Thread.Sleep(2000);
            var processs = Process.GetProcesses().Where(i => i.ProcessName.Contains("VSTO")).ToList();
            foreach (var item in processs)
            {
                if (item.ProcessName.Contains("VSTO"))
                {                   
                    item.EnableRaisingEvents = true;
                    item.Exited += ExcelProcessExit; // this method will be executed after vsto completes it's installation or user cancels the installer.
                }
            }

Upvotes: 0

Related Questions