提供用户安装 Mysql (NSIS)

Offer user to install Mysql (NSIS)

我正在尝试为我的程序制作安装程序。它使用 Mysql,我想提供给用户安装它。我怎样才能通过 NSIS 做到这一点?

这是我的安装脚本

OutFile "setup.exe"

InstallDir $PROGRAMFILES\MYApp\ 

Page directory
Page instfiles

Section ""
  SetOutPath $INSTDIR\MYApp
   File C:\ForSetup\*.*
SectionEnd
    Section ""
  SetOutPath $INSTDIR\MYApp
   File C:\ForSetup\*.*

 MessageBox MB_YESNO "Mysql is required. Do you want to install it ?" /SD IDYES IDNO endWork
    ExecWait '"$SYSDIR\msiExec" /i "mysql-installer-web-community-5.6.22.0.msi"'

     endWork:
     ; the end
SectionEnd

使用 nsDialogs 或 InstallOptions 创建自定义页面:

!include LogicLib.nsh
!include nsDialogs.nsh
!include Sections.nsh

Page Custom MyPageCreate MyPageLeave
Page InstFiles

Section "Foo v1.2.3.4" SID_INSTALLFOO
MessageBox mb_ok "Installing Foo"
SectionEnd


Var MyCheckboxHandle

Function MyPageCreate
nsDialogs::Create 1018
Pop [=10=] ; [=10=] is "error" if there was a problem

${NSD_CreateLabel} 10u 10u 100% 12u "Hello world, blah blah blah blah?"
Pop [=10=]

${NSD_CreateCheckBox} 15u 30u 50% 12u "Install Foo v1.2.3.4"
Pop $MyCheckboxHandle
${NSD_Check} $MyCheckboxHandle

nsDialogs::Show
FunctionEnd

Function MyPageLeave
${NSD_GetState} $MyCheckboxHandle [=10=]
${If} [=10=] <> 0
    !insertmacro SelectSection ${SID_INSTALLFOO}
${Else}
    !insertmacro UnselectSection ${SID_INSTALLFOO}
${EndIf}
FunctionEnd