我有一个.msi文件和两个先决条件文件。按照我的代码,安装程序成功安装后将从.msi文件执行主exe文件。但是,如果.msi文件的前一个版本已经安装,那么它附带了修复和删除的选项。我的Run部分在卸载.msi文件后运行,我希望在应用程序删除msi文件后退出它,否则它将不会执行Run部分。有人能给我一些解决办法吗?
以下是我的Run部分:
[Run]
Filename: "{app}\{#MyAppExeName}"; \
Parameters: "/verysilent /group=""{groupname}\Macrowire 2.5 Pro"" /mergetasks=""desktopicon,file_association"""; \
Flags: nowait postinstall; \
Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; \
StatusMsg: "Installing Macrowire 2.5 Pro..."这是我的Pascal代码:
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
ResultCode: integer;
begin
...
if IsComponentSelected('Macrowire') or IsComponentSelected('Full') then
begin
ShellExec('', ExpandConstant('{app}\MacroWire 2.5 Pro.msi'), '', '', SW_SHOW,
ewWaitUntilTerminated, ResultCode)
end;
...
end;发布于 2016-05-10 08:39:41
当依赖项无法安装时,您可能希望中止安装:
function PrepareToInstall(var NeedsRestart: Boolean): String;
var
ResultCode: integer;
begin
...
if IsComponentSelected('Macrowire') or IsComponentSelected('Full') then
begin
{ Using Exec, the ShellExec is an overkill }
Exec(ExpandConstant('{app}\MacroWire 2.5 Pro.msi'), '', '', SW_SHOW,
ewWaitUntilTerminated, ResultCode);
// Here we are testing the existence of the installed binary.
// A more generic solution would be to test result code of the installer:
// if ResultCode <> 0 then
if not FileExists(ExpandConstant('{app}\{#MyAppExeName}')) then
begin
Result := 'Failed to install MacroWire';
Exit;
end;
end;
...
end;如果希望继续安装,但只需要跳过[Run]条目,则使用 parameter
[Run]
Filename: "{app}\{#MyAppExeName}"; Parameters: "..."; Flags: nowait postinstall; \
Description: "..."; Check: FileExists(ExpandConstant('{app}\{#MyAppExeName}'))顺便说一句,StatusMsg参数不与postinstall条目一起使用。我仍然不确定安装程序之类的Parameters是否与这个程序相关。
https://stackoverflow.com/questions/37131619
复制相似问题