在我的设置中,我必须安装一个外部驱动程序。
在极少数情况下,安装失败,因此我必须删除旧驱动程序并重新启动,然后才能重试。
我将外部驱动程序安装在中ssPostInstall
。
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
if Exec(ExpandConstant('{app}\external.exe'), '-install', '', SW_SHOW,
ewWaitUntilTerminated, ResultCode) then
begin
{ handle success if necessary; ResultCode contains the exit code }
end
else begin
{ handle failure if necessary; ResultCode contains the error code }
bReboot := true;
end;
end;
function NeedRestart(): Boolean;
begin
Result := bReboot;
end;
不幸的是,这是行不通的,因为NeedRestart
之前已经调用过ssPostInstall
。
还有其他方法可以触发重启吗?
我不想定AlwaysRestart = yes
我可以弹出一个MsgBox
通知用户,并告诉他们该怎么做。但是,如果可以在安装程序中自动进行处理,那就更好了。
您可以尽快进行安装。例如,在external.exe
安装后立即使用AfterInstall
:
[Files]
Source: "external.exe"; DestDir: "{app}"; AfterInstall: InstallDriver
[Code]
procedure InstallDriver;
begin
if Exec(ExpandConstant('{app}\external.exe'), '-install', '', SW_SHOW,
ewWaitUntilTerminated, ResultCode) then
begin
{ handle success if necessary; ResultCode contains the exit code }
end
else
begin
{ handle failure if necessary; ResultCode contains the error code }
bReboot := true;
end;
end;
另一个选择是使用ssInstall
step(甚至PrepareToInstall
event)并使用编程方式提取文件ExtractTemporaryFile
。
顺便说一句,如果external.exe
仅是安装程序,则可能需要将其“安装”到{tmp}
(使其自动删除)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句