How to have the user select what type of install?
I have an application that has client and server components to it. I want the user to be able to choose which one to install and depending on what they choose, different actions will be taken. i.e. Install different files, call other apps, etc. I have an nsis script working that will install the server components, but I need to add a choice and a way to only install certain things. Any help would be great or at least point me to an example that does something like this.
Here is my current script:
;--------------------------------
;Includes
!include "MUI2.nsh"
!include "InstallOptions.nsh"
!include "fileassoc.nsh"
!include "LogicLib.nsh"
!include "x64.nsh"
;--------------------------------
;General
;Name and file
Name "Open Source Automation"
OutFile "OSA Setup v0.3.2.exe"
;Default installation folder
InstallDir "C:\OSA"
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
CRCCheck on
XPStyle on
ShowInstDetails show
BrandingText "OSA Installer"
;--------------------------------
;Pages
!insertmacro MUI_PAGE_LICENSE "License.txt"
#!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections
; These are the programs that are needed by OSA.
Section -Prerequisites
SetOutPath $INSTDIR
IfFileExists "$WINDIR\Microsoft.NET\Framework\v4.0*" NETFrameworkInstalled 0
File "dotNetFx40_Full_setup.exe"
ExecWait "$INSTDIR\dotNetFx40_Full_setup.exe"
Goto endNet
NETFrameworkInstalled:
DetailPrint "Microsoft .NET Framework is already installed!"
endNet:
${If} ${RunningX64}
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x64" 'Installed'
${If} $0 == 1
DetailPrint "VC++ 2011 Redist. already installed"
${Else}
DetailPrint $0
File "vcredist_x64.exe"
ExecWait "$INSTDIR\vcredist_x64.exe"
Delete "$INSTDIR\vcredist_x64.exe"
Goto endVC
${EndIf}
${Else}
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86" 'Installed'
${If} $0 == 1
DetailPrint "VC++ 2011 Redist. already installed"
${Else}
DetailPrint $0
File "vcredist_x86.exe"
ExecWait "$INSTDIR\vcredist_x86.exe"
Delete "$INSTDIR\vcredist_x86.exe"
Goto endVC
${EndIf}
${EndIf}
endVC:
IfFileExists "$PROGRAMFILES\MySQL" MySqlInstalled 0
MessageBox MB_YESNO "Install MySql?" /SD IDYES IDNO endMysql
File "mysql-essential-5.1.50-win32.msi"
;File "mysql-workbench-gpl-5.2.34.2-win32.msi"
ExecWait 'msiexec /q /log $INSTDIR\MySQLINstall.log /i mysql-essential-5.1.50-win32.msi installdir="$PROGRAMFILES\MySql"'
ExecWait 'msiexec /q /log $INSTDIR\MySQLWKINstall.log /i mysql-workbench-gpl-5.2.34.2-win32.msi'
SetOutPath "$PROGRAMFILES\MySql"
File "my.ini"
ExecWait '"$PROGRAMFILES\MySql\bin\mysqld.exe" --install MySQL --defaults-file="$PROGRAMFILES\MySql\my.ini"'
ExecWait '"$PROGRAMFILES\MySql\bin\MySQLInstanceConfig.exe" -i -q "-lc:mysql_install_log.txt" ServerType=DEVELOPMENT DatabaseType=MIXED ConnectionUsage=DSS Port=3306 RootPassword=password'
ExecWait "net start MySql"
ExecWait '"$PROGRAMFILES\MySql\bin\mysql" -uroot -ppassword --execute "CREATE USER `root`@`%` IDENTIFIED BY $\'password$\'";'
ExecWait '"$PROGRAMFILES\MySql\bin\mysql" -uroot -ppassword --execute "GRANT ALL ON *.* TO `root`@`%`";'
Goto endMysql
MySqlInstalled:
DetailPrint "MySql is already installed!"
endMysql:
Delete "$INSTDIR\dotNetFx40_Full_setup.exe"
Delete "$INSTDIR\mysql-essential-5.1.50-win32.msi"
;Delete "$INSTDIR\mysql-workbench-gpl-5.2.34.2-win32.msi"
SectionEnd
Section "Open Source Automation Engine" SecDummy
${If} ${RunningX64}
SetRegView 64
${EndIf}
SetOutPath "$INSTDIR"
File "..\DB\0.2.0-0.3.0.sql"
File "..\DB\0.3.0-0.3.1.sql"
File "..\output\ICSharpCode.SharpZipLib.dll"
File "MySql.Data.dll"
File "..\output\OSAE Manager.exe"
File "..\output\OSAE Manager.exe.config"
File "..\output\lib\OSAE.api.dll"
File "..\output\OSAE.GUI.exe"
File "..\output\OSAEService.exe"
File "..\output\OSAEService.exe.config"
File "..\output\PluginDescriptionEditor.exe"
File "..\output\PluginInstaller.exe"
File "..\output\HostView.dll"
File "..\DB\osae.sql"
;File "..\output\vr.exe"
CreateDirectory "Sounds"
CreateDirectory "Logs"
CreateDirectory "Images"
CreateDirectory "AddIns"
CreateDirectory "wwwroot"
CreateDirectory "AddInSideAdapters"
CreateDirectory "AddInViews"
CreateDirectory "contracts"
CreateDirectory "HostSideAdapters"
CreateDirectory "lib"
SetOutPath "$INSTDIR\lib"
File "..\output\lib\OSAE.api.dll"
File "MySql.Data.dll"
SetOutPath "$INSTDIR\AddInSideAdapters"
File "..\output\AddInSideAdapters\Template.dll"
SetOutPath "$INSTDIR\AddInViews"
File "..\output\AddInViews\AddInView.dll"
SetOutPath "$INSTDIR\contracts"
File "..\output\contracts\OpenSourceAutomation.Contract.dll"
SetOutPath "$INSTDIR\HostSideAdapters"
File "..\output\HostSideAdapters\Template.dll"
SetOutPath "$INSTDIR\wwwroot"
File "..\output\wwwroot\*.*"
CreateDirectory "includes"
CreateDirectory "mobile"
CreateDirectory "images"
SetOutPath "$INSTDIR\wwwroot\includes"
File "..\output\wwwroot\includes\*.*"
SetOutPath "$INSTDIR\wwwroot\images"
File "..\output\Images\*.jpg"
File "..\output\Images\*.png"
SetOutPath "$INSTDIR\wwwroot\mobile"
File "..\output\wwwroot\mobile\*.*"
CreateDirectory "includes"
CreateDirectory "css"
CreateDirectory "js"
SetOutPath "$INSTDIR\wwwroot\mobile\includes"
File "..\output\wwwroot\mobile\includes\*.*"
SetOutPath "$INSTDIR\wwwroot\mobile\js"
File "..\output\wwwroot\mobile\js\*.*"
SetOutPath "$INSTDIR\wwwroot\mobile\css"
File "..\output\wwwroot\mobile\css\*.*"
CreateDirectory "images"
SetOutPath "$INSTDIR\wwwroot\mobile\css\images"
File "..\output\wwwroot\mobile\css\images\*.*"
SetOutPath "$INSTDIR\Logs"
SetOutPath "$INSTDIR\Images"
File "..\output\Images\*.jpg"
File "..\output\Images\*.png"
SetOutPath "$INSTDIR\AddIns"
CreateDirectory "Bluetooth"
CreateDirectory "Email"
CreateDirectory "Jabber"
CreateDirectory "Network Monitor"
CreateDirectory "Script Processor"
CreateDirectory "Speech"
CreateDirectory "Weather"
CreateDirectory "Web Server"
SetOutPath "$INSTDIR\AddIns\Bluetooth"
File "..\output\AddIns\Bluetooth\Bluetooth.osapd"
File "..\output\AddIns\Bluetooth\OSAE.Bluetooth.dll"
File "..\output\AddIns\Bluetooth\InTheHand.Net.Personal.dll"
SetOutPath "$INSTDIR\AddIns\Email"
File "..\output\AddIns\Email\Email.osapd"
File "..\output\AddIns\Email\OSAE.Email.dll"
SetOutPath "$INSTDIR\AddIns\Jabber"
File "..\output\AddIns\Jabber\Jabber.osapd"
File "..\output\AddIns\Jabber\OSAE.Jabber.dll"
File "..\output\AddIns\Jabber\agsXMPP.dll"
SetOutPath "$INSTDIR\AddIns\Network Monitor"
File "..\output\AddIns\Network Monitor\Network Monitor.osapd"
File "..\output\AddIns\Network Monitor\OSAE.NetworkMonitor.dll"
SetOutPath "$INSTDIR\AddIns\Script Processor"
File "..\output\AddIns\Script Processor\Script Processor.osapd"
File "..\output\AddIns\Script Processor\OSAE.ScriptProcessor.dll"
SetOutPath "$INSTDIR\AddIns\Speech"
File "..\output\AddIns\Speech\Speech.osapd"
File "..\output\AddIns\Speech\OSAE.Speech.dll"
SetOutPath "$INSTDIR\AddIns\Weather"
File "..\output\AddIns\Weather\Weather.osapd"
File "..\output\AddIns\Weather\OSAE.Weather.dll"
SetOutPath "$INSTDIR\AddIns\Web Server"
File "..\output\AddIns\Web Server\Web Server.osapd"
File "..\output\AddIns\Web Server\OSAE.WebServer.dll"
File "..\output\AddIns\Web Server\HttpServer.dll"
SetOutPath "C:\"
CreateDirectory "PHP"
SetOutPath "C:\PHP"
CreateDirectory "ext"
File "php-cgi.exe"
File "php5.dll"
File "php.ini"
SetOutPath "C:\PHP\ext"
File "php_mysql.dll"
# Start Menu Shortcuts
#SetShellVarContext all
createShortCut "$SMPROGRAMS\OSA\Manager.lnk" "$INSTDIR\OSAE Manager.exe"
createShortCut "$SMPROGRAMS\OSA\Uninstall.lnk" "$INSTDIR\uninstall.exe"
createShortCut "$SMPROGRAMS\OSA\OSAE.GUI.lnk" "$INSTDIR\OSAE.GUI.exe"
#SetShellVarContext all
#ShellLink::SetRunAsAdministrator "$SMPROGRAMS\OSA\Manager.lnk"
#Pop $0
SimpleSC::InstallService "OSAE" "OSAE Service" "16" "2" "$INSTDIR\OSAEService.exe" "" "" ""
Pop $0 ; returns an errorcode (<>0) otherwise success (0)
WriteRegStr HKLM "SOFTWARE\OSAE\DBSETTINGS" "INSTALLDIR" "$INSTDIR"
!insertmacro APP_ASSOCIATE "osapd" "OSA.osapd" "Plugin Description" "$INSTDIR\PluginDescriptionEditor.exe,0" "Open" "$INSTDIR\PluginDescriptionEditor.exe $\"%1$\""
!insertmacro APP_ASSOCIATE "osapp" "OSA.osapp" "Plugin Package" "$INSTDIR\PluginInstaller.exe,0" "Open" "$INSTDIR\PluginInstaller.exe $\"%1$\""
!insertmacro UPDATEFILEASSOC
AccessControl::GrantOnFile \
"$INSTDIR" "(BU)" "GenericRead + GenericWrite"
writeUninstaller $INSTDIR\uninstall.exe
SectionEnd
Section GAC
SetOutPath $INSTDIR
File "DBInstall\GAC\bin\Debug\GAC.exe"
ExecWait "$INSTDIR\GAC.exe"
Goto endGAC
endGAC:
Delete "$INSTDIR\GAC.exe"
SectionEnd
Section DBInstall
SetOutPath $INSTDIR
File "DBInstall\DBInstall\bin\Debug\DBInstall.exe"
ExecWait "$INSTDIR\DBInstall.exe $INSTDIR"
Goto endDBInstall
endDBInstall:
Delete "$INSTDIR\DBInstall.exe"
SectionEnd
;--------------------------------
;Uninstaller Section
Section "Uninstall"
Delete "$INSTDIR\Uninstall.exe"
Delete "$SMPROGRAMS\OSA\Manager.lnk"
Delete "$SMPROGRAMS\OSA\Uninstall.lnk"
Delete "$SMPROGRAMS\OSA\OSAE.GUI.lnk"
Delete "$SMPROGRAMS\OSA\DevTools.lnk"
RMDir /r "$SMPROGRAMS\OSA"
!insertmacro APP_UNASSOCIATE "osapd" "OSA.osapd"
!insertmacro APP_UNASSOCIATE "osapp" "OSA.osapp"
Delete $INSTDIR\*.*
RMDir /r $INSTDIR
SimpleSC::RemoveService "OSAE"
Pop $0
SectionEnd