Subversion Repositories DevTools

Rev

Rev 1141 | Blame | Compare with Previous | Last modification | View Log | RSS feed

;-------------------------------------------------------------------------------
;
;   Example of a NSIS basis Windows Installer suitable for use within the
;    Vix-ERG PCC environment
;
;   This is an example of how things can be done
;   It includes a lot of excess documentation that can be removed
;
;--------------------------------
;   Include Modern UI
;   Provides an Installer that is similar to many other Windows-XP installers
!include "MUI2.nsh"

;--------------------------------
;   General
;   Specify basic settings
;
;   Name            - Already set based on package name and version
;   BrandingText    - Already set
;   Caption         - Already set

;   FileDescription
;       Will be available when the user selects the properties
;       of the installer. All other properties have been set based the
;       package name and version.    
;                       
VIAddVersionKey "FileDescription" "This is a example file description"

;   Default installation folder
;       Existing ERG Apps are installed into c:\AFC\${GBE_PACKAGE}
;       $DESKTOP\${GBE_PACKAGE} - can be useful
;       $PROGRAMFILES\ERG\${GBE_PACKAGE} - could be good too
;   
InstallDir C:\AFC\${GBE_PACKAGE}

;   Get installation folder from registry if available
!define InstallDirReg "Software\ERG\${GBE_PACKAGE}"
InstallDirRegKey HKCU ${InstallDirReg} ""

;   Request application privileges for Windows Vista/7
;   Need admin privileges to modify registry, otherwise use user
RequestExecutionLevel admin

;   Program Group for Shortcuts
!define ProgramGroupBase "ERG"
!define ProgramGroup "${ProgramGroupBase}\${GBE_PACKAGE}"

;--------------------------------
;   Modern Interface Settings

#!define MUI_ABORTWARNING
 !define MUI_ICON                       "${GBE_NSISDATA}\inVix.ico"
 !define MUI_UNICON                     "${GBE_NSISDATA}\unVix.ico"
 !define MUI_HEADERIMAGE
 !define MUI_HEADERIMAGE_BITMAP         "${GBE_NSISDATA}\VixHeader.bmp"
 !define MUI_WELCOMEFINISHPAGE_BITMAP   "${GBE_NSISDATA}\VixPanel.bmp"
 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "${GBE_NSISDATA}\VixPanel.bmp"
 !define MUI_FINISHPAGE_NOAUTOCLOSE
 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
 !define MUI_WELCOMEPAGE_TITLE_3LINES
 !define MUI_FINISHPAGE_TITLE_3LINES

;--------------------------------
;   Pages
;   List of Pages for the Modern UI to show

 !insertmacro MUI_PAGE_WELCOME
#!insertmacro MUI_PAGE_LICENSE "${GBE_NSISDATA}\license.txt"
#!insertmacro MUI_PAGE_COMPONENTS
#!insertmacro MUI_PAGE_DIRECTORY
 !insertmacro MUI_PAGE_INSTFILES
#!insertmacro MUI_PAGE_FINISH

#!insertmacro MUI_UNPAGE_WELCOME
 !insertmacro MUI_UNPAGE_CONFIRM
#!insertmacro MUI_UNPAGE_COMPONENTS
 !insertmacro MUI_UNPAGE_INSTFILES
#!insertmacro MUI_UNPAGE_FINISH
  
;--------------------------------
;   Languages
;   System will select default language
 
  !insertmacro MUI_LANGUAGE "English"
  !insertmacro MUI_LANGUAGE "French"
#  !insertmacro MUI_LANGUAGE "Swedish"
 
;--------------------------------
;   Allow user to select the language
;   By default the system will select the 'system' language
;   Uncomment the following lines and th user can select
;   the installation laguage.
#Function .onInit 
#    !insertmacro MUI_LANGDLL_DISPLAY 
#FunctionEnd

#Function un.onInit 
#    !insertmacro MUI_LANGDLL_DISPLAY 
#FunctionEnd

;--------------------------------
;   Installer Sections
;   Each section will show up as a 'component', if that page is shown
;
Section "Application" SecDummy

    SetOutPath "$INSTDIR"
  
    ; Install a program
    CreateDirectory "$INSTDIR\bin"
    SetOutPath "$INSTDIR\bin"
    File "${GBE_INTERFACE}\bin\WIN32P\AT91load.exe"
  
    ; Create a Short Cut
    SetShellVarContext all
    CreateDirectory "$SMPROGRAMS\${ProgramGroup}"
    CreateShortCut  "$SMPROGRAMS\${ProgramGroup}\AT91load.lnk"  "$INSTDIR\bin\AT91load.exe"
    CreateShortCut  "$SMPROGRAMS\${ProgramGroup}\UnInstall ${GBE_PACKAGE}.lnk" "$INSTDIR\Uninstall.exe"
    IfErrors 0 +2
        Abort "Error creating Application Shortcut"

    ; Create a Desktop Icon     
    CreateShortCut "$DESKTOP\AT91load.lnk" "$INSTDIR\bin\AT91load.exe"
    IfErrors 0 +2
        Abort "Error creating Desktop Icon"
  
    ; Install a data file
    CreateDirectory $INSTDIR\data
    SetOutPath "$INSTDIR\data"
    File /oname=datafile.txt example.nsi
  
    IfErrors 0 +2
        Abort "Error Installing Application"
  
SectionEnd

;--------------------------------
;   Uninstaller Sections
;   Un Installer for files installed by the user
;
Section "un.Application"
  ;
  ; Remove the data file
  Delete "$INSTDIR\data\datafile.txt"
  RMDir  "$INSTDIR\data"
  
  ; Remove the program
  RMDir /r "$INSTDIR\bin"
  
  ; Remove the shortcuts
  SetShellVarContext all
  Delete "$DESKTOP\AT91load.lnk"
  RMDir /r "$SMPROGRAMS\${ProgramGroup}"
  RMDir "$SMPROGRAMS\${ProgramGroupBase}"
  
SectionEnd

;--------------------------------
;   Section to create the Core of the Uninstaller
;   This will be hidden
;
Section "-Core"

    ;Store installation folder
    WriteRegStr HKCU ${InstallDirReg} "" $INSTDIR

    ;Create uninstaller and copy it into the install directory
    SetOutPath "$INSTDIR"
    WriteUninstaller "$INSTDIR\Uninstall.exe"
  
    ; Write the uninstall keys for Windows so that the package is seen in the
    ; Add/Remove Program section of the Control Panel.
    ;     Create a 'unique' key in the windows registry
    ;     Base it on the package name
    ;         Could use a GUID but it MUST NOT be copied if this file is copied
    ;
    !define UnInstallKeyBase "Software\Microsoft\Windows\CurrentVersion\Uninstall"
    !define UnInstallKey "${UnInstallKeyBase}\${GBE_PACKAGE}"
  
    WriteRegStr   HKLM ${UnInstallKey} "DisplayName" "${GBE_PACKAGE}"
    WriteRegStr   HKLM ${UnInstallKey} "DisplayVersion" "${GBE_VERSION_FULL}"
    WriteRegStr   HKLM ${UnInstallKey} "Publisher" "${GBE_COMPANY}"
    WriteRegStr   HKLM ${UnInstallKey} "InstallLocation" "$INSTDIR"
    WriteRegStr   HKLM ${UnInstallKey} "UninstallString" '"$INSTDIR\uninstall.exe"'
    WriteRegStr   HKLM ${UnInstallKey} "DisplayIcon" '"$INSTDIR\uninstall.exe"'
    WriteRegDWORD HKLM ${UnInstallKey} "NoModify" 1
    WriteRegDWORD HKLM ${UnInstallKey} "NoRepair" 1
    
    IfErrors 0 +2
        Abort "Error creating uninstaller information"
    
SectionEnd

;--------------------------------
;   Uninistaller section to uninstall keys
;   That have been installed as a part of the core installer
;
Section "-un.Core"

  ; Delete the uninstaller and then the containing directory
  ; The directory will only be removed if its empty  
  Delete "$INSTDIR\Uninstall.exe"
  RMDir "$INSTDIR"

  ; Remove the programs registry key
  ;     Keep around for next time
  ; DeleteRegKey /ifempty HKCU ${InstallDirReg}

  ; Remove Uninstaller registry keys
  DeleteRegKey HKLM ${UnInstallKey}
  
SectionEnd