Embedding other installers: Difference between revisions
(Added the example for the Error chacking after an ExecWait) |
(wSoPyZ Im grateful for the post.Thanks Again. Keep writing.) |
||
Line 1: | Line 1: | ||
Oftentimes one runs an installer that contains installers for other programs. For example, I wrote an application for a client that has a pocket PC component. The installer I wrote for them also installs Active Sync, the .NET CF Version 2 redistributable, and ntbackup being many of the machines run XP home edition. This page demonstrates how to do this. | Oftentimes one runs an installer that contains installers for other programs. For example, I wrote an application for a client that has a pocket PC component. The installer I wrote for them also installs Active Sync, the .NET CF Version 2 redistributable, and ntbackup being many of the machines run XP home edition. This page demonstrates how to do this. | ||
wSoPyZ Im grateful for the post.Thanks Again. Keep writing. | |||
= Now for theory = | = Now for theory = |
Revision as of 15:24, 22 March 2012
Oftentimes one runs an installer that contains installers for other programs. For example, I wrote an application for a client that has a pocket PC component. The installer I wrote for them also installs Active Sync, the .NET CF Version 2 redistributable, and ntbackup being many of the machines run XP home edition. This page demonstrates how to do this.
wSoPyZ Im grateful for the post.Thanks Again. Keep writing.
Now for theory
The process is simple. Copy the file over and execute it. Use ExecWait to pause your installer until the embedded installer is finished. In theory you could capture the return value of the installer and react to it. I've yet to explore this avenue. In the example above the installers were MSI's and not exes so I have to execute the installers with msiexec /i <installer.msi>.
Using the return value from the ExecWait
This is the bit of code I have been using for installing dotnet 2 where needed. I'll skip over the Check function (it will return 1 if it is installed). I needed IfErrors before the ExecWait to clear the error flag. The IfErrors after the ExecWait will return true if the execution returned an error (usually meaning an exitcode != 0 or for example if the user aborted the dotnet installer). In that case it will jump to the appropriate label and Abort. If everything is OK, it will delete the dotnet installer and continue.
Call CheckFrameWork Pop $0 ${if} $0 != "1" IfErrors continue continue: File "dotnetfx.exe" ExecWait '"$INSTDIR\dotnetfx.exe"' IfErrors error_installing_dotnet ${endif} Delete $INSTDIR\dotnetfx.exe goto done error_installing_dotnet: Abort done: Delete $INSTDIR\dotnetfx.exe
A more complex example
This is a real world example. I use this to install several programs on computers for a client of mine. I then install the Application I wrote for the client using a NSIS script. You will need to download several binaries to get this script to compile.
; Script generated by the HM NIS Edit Script Wizard. ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "App Deploy" !define PRODUCT_VERSION "1.0" !define PRODUCT_PUBLISHER "ZippySoft" SetCompressor lzma !include "UserManagement.nsh" ; MUI 1.67 compatible ------ !include "MUI.nsh" ; MUI Settings !define MUI_ABORTWARNING !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" ; Welcome page !insertmacro MUI_PAGE_WELCOME ; Components page !insertmacro MUI_PAGE_COMPONENTS ; Instfiles page !insertmacro MUI_PAGE_INSTFILES ; Finish page !insertmacro MUI_PAGE_FINISH ; Language files !insertmacro MUI_LANGUAGE "English" ; Reserve files !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS ; MUI end ------ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "AppDeploy.exe" InstallDir "$PROGRAMFILES\App Deploy" ShowInstDetails show Section -SETTINGS SetOutPath "$INSTDIR" SetOverwrite ifnewer SectionEnd Section "Epson Stylus C88+" SEC01 File "drivers\epson11896.exe" ExecWait "$INSTDIR\epson11896.exe" SectionEnd Section "Polaroid PDC700" SEC02 MessageBox MB_OK \ "The TWAIN drivers for Polaroid PDC700 are about to be installed. The Polaroid installer \ will ask you to reboot. Please say no to this reboot request. The AppDeploy installer will \ prompt you after installing all the other applications." File "drivers\pdc700_twain_driver.exe" ExecWait "$INSTDIR\pdc700_twain_driver.exe" AccessControl::GrantOnFile "C:\WINDOWS\twain_32\PDC700" "(BU)" "GenericRead + GenericWrite" SetRebootFlag true SectionEnd Section "FireFox" SEC03 ; To upgrade this package http://www.frontmotion.com/Firefox/fmfirefox.htm File "firefox\FMFirefoxCE-2.0-en-US.msi" ExecWait 'msiexec /i "$INSTDIR\Firefox Setup 2.0.exe" /passive ' SectionEnd Section "PDFCreator" SEC04 File "PDFCreator\zPDFCreator-0_9_3-AD_DeploymentPackage-WithoutToolbar.msi" ExecWait '"msiexec" /i "$INSTDIR\zPDFCreator-0_9_3-AD_DeploymentPackage-WithoutToolbar.msi" /passive' SectionEnd Section "The GIMP" SEC05 File "GIMP\gtk+-2.10.6-1-setup.exe" File "GIMP\gimp-2.2.13-i586-setup-1.exe" ExecWait '"gtk+-2.10.6-1-setup.exe" /SP- /SILENT' ExecWait '"gimp-2.2.13-i586-setup-1.exe" /SP- /SILENT' SectionEnd Section "7Zip" SEC06 File "7z442.msi" ExecWait '"msiexec" /i "$INSTDIR\7z422.msi" /passive' SectionEnd Section "PlaneDisaster.NET" SEC07 File "PlaneDisaster.NET Setup.msi" ExecWait '"msiexec" /i "$INSTDIR\PlaneDisaster.NET Setup.msi" /passive' SectionEnd Section "Adobe Acrobat Reader 8" SEC08 ; For information on Deploying acrobat reader 8 see http://www.appdeploy.com/packages/detail.asp?id=915 File "AdbeRdr80_en_US.exe" ExecWait 'AdbeRdr80_en_US.exe /sPB /rs /l /msi"/qb-! /norestart /log c:\acrobat8.log ALLUSERS=2 EULA_ACCEPT=YES SUPPRESS_APP_LAUNCH=YES"' SectionEnd
External Links
- http://www.appdeploy.com/packages/ Information on how to deploy many popular programs. Also information on MSI and MST tools.
- http://www.frontmotion.com/Firefox/fmfirefox.htm An MSI for FireFox.