[英]Inno Setup: Install other installer and run it before continuing my install
到目前為止,這是我代碼的 [Files] 部分:
[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”和其余部分。
我在 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}"
更好的方式可能是AfterInstall
參數。 以下腳本將在處理OtherInstaller.exe
文件條目后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;
另一個運行先決條件安裝程序的好時機是在PrepareToInstall
事件函數中。 (有關基本結構,請參閱 Inno 提供的示例腳本,以及實際執行的 TLama 代碼。)
PrepareToInstall
的主要優點是它允許您處理來自子安裝程序的錯誤和重新啟動請求——而使用AfterInstall
則不然。
它的主要缺點是您必須手動ExtractTemporaryFile
運行子安裝所需的任何內容,因為這是在提取文件之前發生的。
您可以使用 AfterInstall,在幫助中查找。 剛剛復制文件時,我將啟動您放置為“AfterInstall:”的功能/過程。
在此功能/過程中,使用 Exec 並啟動其他安裝程序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.