2013-10-25 196 views
20

这是我的代码[文件]部分至今之前运行它:创新安装:安装其他安装程序,并继续我的安装

[Files] 
Source: "other_installer.exe"; DestDir: "{app}" 
Source: "myprogram.exe"; DestDir: "{app}" 
Source: "data.dat"; DestDir: "{app}" 
Source: "otherdata.dat"; DestDir: "{app}" 

我的程序是依赖于其他程序来运行。我已在我的安装程序中包含此程序的安装程序(“other_installer.exe”)。我想要做的就是在复制完成后立即启动此安装程序,然后继续执行“myprogram.exe”和其他操作。

我已经使用Google搜索并在Inno Setup Help中找到了BeforeInstall的文档,但他们没有运行其他应用程序的示例。我相信它应该是这样的:

[Files] 
Source: "other_installer.exe"; DestDir: "{app}" 
Source: "myprogram.exe"; DestDir: "{app}"; BeforeInstall: // RUN OTHER_INSTALLER.EXE // 
Source: "data.dat"; DestDir: "{app}" 
Source: "otherdata.dat"; DestDir: "{app}" 

回答

24

更好地为你去可能是AfterInstall参数的方式。以下脚本将在处理OtherInstaller.exe文件条目后立即执行RunOtherInstaller功能。它会尝试执行刚刚安装的OtherInstaller.exe文件,如果失败,它会向用户报告错误消息。请注意,您不能中断从功能安装,所以没有太多安全做你想要的东西是这样的:

[Setup] 
AppName=My Program 
AppVersion=1.5 
DefaultDirName={pf}\My Program 

[Files] 
Source: "OtherInstaller.exe"; DestDir: "{app}"; AfterInstall: RunOtherInstaller 
Source: "OtherFile.dll"; DestDir: "{app}" 

[Code] 
procedure RunOtherInstaller; 
var 
    ResultCode: Integer; 
begin 
    if not Exec(ExpandConstant('{app}\OtherInstaller.exe'), '', '', SW_SHOWNORMAL, 
    ewWaitUntilTerminated, ResultCode) 
    then 
    MsgBox('Other installer failed to run!' + #13#10 + 
     SysErrorMessage(ResultCode), mbError, MB_OK); 
end; 
+0

稍后可以存储错误和中断(并可能回滚)安装吗? – Septagram

0

您可以使用AfterInstall,帮助在寻找这个。 当文件刚刚被复制时,我将启动您放置为“AfterInstall:”的函数/过程。

在此函数/过程中,使用Exec并启动其他安装程序。

+0

是的,如果我的答案和你的答案类似,我很抱歉 –

8

运行必备安装程序的另一个好时机是在PrepareToInstall事件函数中。 (请参阅基本结构提供的Inno示例脚本,并TLama对实际执行代码。)

PrepareToInstall的主要优点是,它可以让你处理从孩子的安装错误和重新启动请求 - 使用AfterInstall没有。

它的主要缺点是您必须手动ExtractTemporaryFile运行孩子安装所需的任何东西,因为这发生在文件被提取之前。

相关问题