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 ?
Type "start [filename.exe]" into Command Prompt, replacing "filename" with the name of your selected file. Replace "[filename.exe]" with your program's name. This allows you to run your program from the file path.
Go to Menu, Project, then Compile to compile and create the setup file. This will create a complete installer. Run the Setup and your application will be installed correctly. Innosetup offers an awesome alternative to create great looking Installers for free.
You can run the commands stored in a CMD file in Windows by double-clicking the file or executing it in the Command Prompt (CMD. EXE) utility.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With