我正在准备一个 inno 安装程序以同时安装 Windows 窗体应用程序和 Office 加载项。 我在安装过程中部署了所有 Windows 窗体文件(exe 和 dll)和 Office 加载项部署文件,一切正常。 但最后,当办公室插件“setup.exe”仍在运行时,我看到了“安装完成”屏幕。我不关心看到其他已安装的应用程序在后台运行或弹出,但我不喜欢 inno setup 在其他应用程序运行时说“完成”。
这是我的代码:
[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”目录后立即运行... 所以,我可能只需要正确的事件来覆盖。
最佳答案
您提交的代码可以增强为:
[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 函数,在我看来,就像一个快捷方式,所以给应用程序一个 workingdir。因为我不知道您的 Setup.exe 的性质,所以我将此应用程序指定为 workingdir,与应用程序所在的文件夹相同。
有点题外话: 在最终版本中使用 SW_Hide。 如果选择除 SW_HIDE 之外的其他模式,则始终可以看到应用程序已安装插件的结果 :)
关于visual-studio - 设置 Inno 以运行 Office 加载项安装程序并等待它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12921326/