如何使 Inno 安装程序安装程序在安装完成后或 VSTO 安装程序完成后保留临时文件?



我有Inno Setup安装程序(在我之前编写(,它可以提取一组VSTO文件,然后启动VSTO MS Office插件安装。它有一个问题,即将 VSTO 文件提取到临时文件夹并启动VSTOInstaller.exe时,它会立即显示"完成">按钮。如果用户单击它,则会删除临时文件,并在VSTOInstaller中开始实际安装 VSTO 加载项,然后导致"找不到文件"错误。我应该解决这个问题(理想情况下,仅在 Inno Setup 安装程序中生成VSTOInstaller完成执行时才显示完成按钮(。

VSTO 包本身("应用程序文件"文件夹、setup.exe.vsto文件的集合(由 Visual Studio 中的 ClickOnce 发布工具创建。包裹经过数字签名等。

我尝试了各种选择:

  • 在打开.vsto文件的进程完成之前不完成 Inno 安装程序安装(带有waituntilterminated标志(。不起作用,似乎在打开.vsto文件期间进程发生了变化,VSTOInstaller不是链中的第一个进程。因此,Inno Setup只等待快速将执行传递给另一个进程(VSTOInstaller(然后关闭的进程。
  • 安装时不删除提取的文件(带有uninsneveruninstall标志(。看起来它仅适用于卸载,而在安装过程中删除临时文件有些不同。完成安装后,我没有找到任何方法可以保持解压缩的文件完好无损。

当前.iss文件如下所示:

;---------------------------------------------------------------------
[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

最初,安装程序运行setup.exe而不是OutlookAddin.vsto。这导致setup.exe启动VSTOInstaller.exe并立即关闭。我以为更改为OutlookAddin.vsto(并添加shellexec标志(可以解决这个问题,以便通过此方法直接启动VSTOInstaller.exe但不起作用。事实证明.vsto文件是由vstoee.dll首先打开的。

知道如何保留解压缩的文件(它们将保留在临时文件夹中没什么大不了的(或以某种方式等待在设置过程中生成的所有子进程?

如果这很重要,Inno Setup是5.2.3,VSTO是使用Visual Studio 2015构建的。使用 Outlook 2010 和 2016 进行测试。

{tmp}是安装程序的临时文件夹,最后会被删除。如果要保留文件,请使用环境变量显式引用用户的临时文件夹TEMP

DefaultDirName={%TEMP}outlook_addin_tmp

虽然这是一个黑客 - 正确的解决方案是等待VSTO安装程序完成。我建议你明确地开始VSTOInstaller.exe。它应该允许您等待它完成

像这样:

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

我最近创建了与 u 要求相同的内容。 它对我来说工作正常,开始设置.exe然后搜索 VSTO 进程并将退出事件绑定到它。

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.
}
}

最新更新