For installing MySQL silently, I tried following command in cmd and it works fine:
msiexec /i "mysql-essential-6.0.11-alpha-winx64.msi" /qn
But, how can I run that command Before Installing in Inno Setup ?
For installing MySQL silently, I tried following command in cmd and it works fine:
msiexec /i "mysql-essential-6.0.11-alpha-winx64.msi" /qn
But, how can I run that command Before Installing in Inno Setup ?
You can execute it by calling Exec
function from the CurStepChanged
event method, when the step will be ssInstall
. In the following script is shown, how to include that MySQL installer into your setup and how to extract and execute it right before the installation starts:
#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;
Utilize the unused progress bar:
Since it takes some time before the installation of MySQL finishes, and you've decided to hide the user interface of the installer (what might also be quite unsafe anyway), you can extend the script to use the progress bar which is shown at its starting position during the installation and which is unused that time. The following code switches (on at least Windows XP systems) the Inno Setup's installation progress bar to marquee style
and shows a description in the status label. When MySQL installation is done, the progress bar is switched back to the normal mode and the actual Inno Setup installation starts:
#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;