提供用户安装Mysql(NSIS)

时间:2015-01-20 12:38:15

标签: mysql installation nsis

我试图为我的程序安装程序。它使用Mysql,我想为用户提供安装它。我怎么能通过NSIS做到这一点?

这是我的安装脚本

OutFile "setup.exe"

InstallDir $PROGRAMFILES\MYApp\ 

Page directory
Page instfiles

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

2 个答案:

答案 0 :(得分:1)

使用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 $0 ; $0 is "error" if there was a problem

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

${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 $0
${If} $0 <> 0
    !insertmacro SelectSection ${SID_INSTALLFOO}
${Else}
    !insertmacro UnselectSection ${SID_INSTALLFOO}
${EndIf}
FunctionEnd

答案 1 :(得分:0)

    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