3

我正在准备一个 inno 设置来同时安装一个 windows 窗体应用程序和一个 office 插件。我在安装期间部署了所有 Windows 窗体文件(exe 和 dll)和 office 插件部署文件,一切正常。但最后,当office插件“setup.exe”仍在运行时,我得到了“安装完成”屏幕。我不关心在后台看到其他安装的运行或弹出窗口,但我不喜欢在其他应用程序运行时 inno 设置说“完成”。

这是我的代码:

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

所以,它不服从“runminimized”,无论如何我都很好......但它也不服从“waituntilterminated”,我很在意。

请注意,“AddIn\Deploy\setup.exe”是 Visual Studio 通过 office 插件的“发布”向导生成的文件。

如果我只能运行此代码,我会很高兴:

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

但是,我必须在主 inno 安装程序将文件复制到“AddIn\Deploy”目录之后立即运行......所以,我可能只需要正确的事件来覆盖。

4

1 回答 1

4

您提交的代码可以增强为:

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

{app} 可能包含空格,如果字符串包含空格,则 AddQuotes 函数会在字符串周围创建引号。在我看来,exec 函数就像一个快捷方式,所以给应用程序一个工作目录。因为我不知道您的 Setup.exe 的性质,所以我将此应用程序作为 workingdir 与应用程序所在的文件夹相同。

有点题外话:在最终版本中使用 SW_Hide。如果选择了除 SW_HIDE 以外的其他模式,则始终可以看到应用程序安装插件的结果:)

于 2013-11-19T10:15:50.997 回答