为了静默安装 MySQL,我在 cmd 中尝试了以下命令,它工作正常:
msiexec /i "mysql-essential-6.0.11-alpha-winx64.msi" /qn
但是,如何在 Inno Setup 中安装之前运行该命令?
为了静默安装 MySQL,我在 cmd 中尝试了以下命令,它工作正常:
msiexec /i "mysql-essential-6.0.11-alpha-winx64.msi" /qn
但是,如何在 Inno Setup 中安装之前运行该命令?
Exec
您可以通过从事件方法调用函数来执行它CurStepChanged
,当步骤为ssInstall
. 在以下脚本中显示了如何将该 MySQL 安装程序包含到您的设置中,以及如何在安装开始之前提取并执行它:
#define MySQLInstaller "mysql-essential-6.0.11-alpha-winx64.msi"
[Files]
Source: "{#MySQLInstaller}"; Flags: dontcopy
[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
Params: string;
ResultCode: Integer;
begin
if (CurStep = ssInstall) then
begin
ExtractTemporaryFile('{#MySQLInstaller}');
Params := '/i ' + AddQuotes(ExpandConstant('{tmp}\{#MySQLInstaller}')) + ' /qn';
if not Exec('msiexec', Params, '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
MsgBox('Installation of MySQL failed. Exit code: ' + IntToStr(ResultCode),
mbInformation, MB_OK);
end;
end;
利用未使用的进度条:
由于 MySQL 安装完成需要一些时间,并且您决定隐藏安装程序的用户界面(无论如何这也可能非常不安全),您可以扩展脚本以使用显示在其安装期间的起始位置,当时未使用。以下代码将 Inno Setup 的安装进度条切换(至少在 Windows XP 系统上)marquee style
并在状态标签中显示描述。MySQL 安装完成后,进度条切换回正常模式,开始实际的 Inno Setup 安装:
#define MySQLInstaller "mysql-essential-6.0.11-alpha-winx64.msi"
[Files]
Source: "{#MySQLInstaller}"; Flags: dontcopy
[Code]
procedure CurStepChanged(CurStep: TSetupStep);
var
Params: string;
ResultCode: Integer;
begin
if (CurStep = ssInstall) then
begin
WizardForm.ProgressGauge.Style := npbstMarquee;
WizardForm.StatusLabel.Caption := 'Installing MySQL. This may take a few minutes...';
ExtractTemporaryFile('{#MySQLInstaller}');
Params := '/i ' + AddQuotes(ExpandConstant('{tmp}\{#MySQLInstaller}')) + ' /qn';
if not Exec('msiexec', Params, '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
MsgBox('Installation of MySQL failed. Exit code: ' + IntToStr(ResultCode),
mbInformation, MB_OK);
WizardForm.ProgressGauge.Style := npbstNormal;
WizardForm.StatusLabel.Caption := '';
end;
end;