WISDOMBAY

in4mation ... organized

Dealing with NSIS made Simpler

Page 2

Posted by Mohammed Arfath

Step 3 : Coding section

Now go to the NSIS installation folder (eg: “C:\Program Files\NSIS\”).

Go to the location “<NSIS folder>\Contrib\Ziptoexe\”.

Here you can find a file named Modern.nsh.

Change it's content with the below given code for creating an installer for the above given scenario.

;this is a comment statement
;Change this file to customize zip2exe generated installers with a modern interface

!include "MUI.nsh"
!include "Sections.nsh"

SetDateSave on
SetDatablockOptimize on
CRCCheck on
SilentInstall normal
XPStyle on

;variable initialization
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;CHANGE THE BELOW GIVEN SECTION’S TO MATCH YOUR
;PRODUCT AND FILES DETAILS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

!define product_name "Myapp"
;give the full path name for license_file
!define license_file "D:\Nsis\Test\Mylicensefile.rtf"
!define application_name "myexe.exe"
;give the full path name for background_image
!define background_image "D:\Nsis\Test\backgroundimage.bmp"
;give the full path name for header_image
!define header_image "D:\Nsis\Test\headerimage.bmp"
;give the full path name for welcomefinishimage
!define welcomefinishimage "D:\Nsis\Test\welcomefinishimage.bmp"
;give the full path name for inst_icon
!define inst_icon "D:\Nsis\Test\installericon.ico"
;give the full path name for uninst_icon
!define uninst_icon "D:\Nsis\Test\uninstallericon.ico"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;Note that the installer icon and unistallericon must be of same size and colour depth.try with same icons for both at first.then try other icons.

InstallDir "$PROGRAMFILES"

;Define General Interface Characteristics...
!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit
!define MUI_ABORTWARNING
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${header_image}"
!define MUI_WELCOMEFINISHPAGE_BITMAP "${welcomefinishimage}"
!define MUI_COMPONENTSPAGE_SMALLDESC
BrandingText "Wisdom Bay"
!define MUI_WELCOMEPAGE_TITLE "Welcome to the ${product_name} Setup Wizard"
!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of ${product_name}"


;Insert Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "${license_file}"
icon "${inst_icon}"
UninstallIcon "${uninst_icon}"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_LINK " Visit Wisdom Bay site for the latest news, FAQs and support $\n http://www.wisdombay.com/"
!define MUI_FINISHPAGE_LINK_LOCATION "http://www.wisdombay.com/"
;;uncomment the following line if you want to run your application after installation
;!define MUI_FINISHPAGE_RUN "$INSTDIR\${product_name}\${application_name}"

!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
!insertmacro MUI_LANGUAGE "English"


;;all the codings that should be executed at runtime should come under sections. you can add any number of sections, just be careful to give unique names for sections
section "-${product_name}(required)"

setoutpath "$INSTDIR\${product_name}"
WriteRegStr HKLM "SOFTWARE\${product_name}" "Install_Dir" "$INSTDIR"


Google