【发布时间】:2013-01-09 10:04:53
【问题描述】:
我希望软件安装程序在一个安装程序完成安装后执行另一个 exe/安装程序。无论使用哪个安装程序(NSIS、Inno Setup 等)来制作它,我都只想这样做。
有可能吗?
【问题讨论】:
标签: inno-setup nsis
我希望软件安装程序在一个安装程序完成安装后执行另一个 exe/安装程序。无论使用哪个安装程序(NSIS、Inno Setup 等)来制作它,我都只想这样做。
有可能吗?
【问题讨论】:
标签: inno-setup nsis
您可以将[RUN] 部分与parameters 和标准或自定义Checks 一起使用。
记住设置priorate Flags - waituntilterminated 使安装程序脚本等到一个启动完成它的操作,然后启动下一个。
例子:
[Files]
Source: "C:\MyInstallers\*"; DestDir: "{tmp}";
Flags: createallsubdirs recursesubdirs deleteafterinstall ignoreversion uninsremovereadonly
[Run]
Filename: "{tmp}\dotnetfx35.exe"; Parameters: "/q";
Flags: waituntilterminated skipifdoesntexist;
StatusMsg: "Instalacja bibliotek Microsoft .NET Framework 3.5 SP1...";
OnlyBelowVersion: 0,6.2.8400; Check: NET35
Filename: "{tmp}\vcredist_x86.exe"; Parameters: "/Q";
Flags: waituntilterminated skipifdoesntexist;
StatusMsg: "Instalacja bibliotek Microsoft Visual C++ 2008 (x86)...";
Check: not Is64BitInstallMode
Filename: "{tmp}\vcredist_x64.exe"; Parameters: "/Q";
Flags: waituntilterminated skipifdoesntexist;
StatusMsg: "Instalacja bibliotek Microsoft Visual C++ 2008 (x64)...";
Check: Is64BitInstallMode
Filename: "{tmp}\directx\DXSETUP.exe"; Parameters: "/silent";
Flags: waituntilterminated skipifdoesntexist;
StatusMsg: "Instalacja bibliotek Microsoft DirectX..."
Filename: "{app}\{#MyAppExeName}"; WorkingDir: "{app}\";
Flags: nowait postinstall runascurrentuser skipifsilent;
Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"
【讨论】:
[Files] 部分。您只需将要复制的文件指向{tmp}。安装过程完成后,安装程序{tmp} 中的所有文件都将被删除。在 C:\MyInstallers 我有我想在[Run] 部分调用的所有其他安装程序(在子文件夹中有 DirectX)。
国家安全局:
Section
InitPluginsDir ; $pluginsdir is a folder in %temp%, it is deleted for you when the installer ends
SetOutPath $PluginsDir
File "child1.exe"
ExecWait '"$PluginsDir\child1.exe" /foo "/bar" /baz'
Delete "$PluginsDir\child1.exe" ; Optional, might be a good idea if the file is large...
File "child2.exe"
ExecWait '"$PluginsDir\child2.exe"'
SetOutPath $Temp ; Don't lock $PluginsDir
SectionEnd
【讨论】:
在 innosetup 中,您还可以使用 ShellExec-Function 进行其他安装。有了它,您可以定义它是否应该在前面,以及主安装是否应该等到这个子安装完成。
这里是一个简短的例子,我在代码部分开始安装 sqltools
if ShellExec('',INSTALL_FOLDER + '\FPS\contributed\sqlncli_x64.msi', '' ,'',SW_HIDE,ewWaitUntilTerminated,ResultCode) then
begin
Log('executed sql native client with result code ' + IntToStr(ResultCode) + ' this means ' + SysErrorMessage(ResultCode));
end
else
begin
showError(CustomMessage('SQLNATIVE_CLIENT_ABORTED') + SysErrorMessage(ResultCode));
end;
【讨论】: