Skip to content
setup.nsi 6.31 KiB
Newer Older
!define AppName "Planimod"
Patrik Dufresne's avatar
Patrik Dufresne committed
!define ShortName "planimod"
Patrik Dufresne's avatar
Patrik Dufresne committed
!define Vendor "Patrik Dufresne Service Logiciel inc."
!define AppExeFile ""

;--------------------------------
;Includes
  !include "MUI2.nsh"
  !include "Sections.nsh"
  !include "x64.nsh"

SetCompressor bzip2
Patrik Dufresne's avatar
Patrik Dufresne committed

  ; Include Java Install
  !addincludedir ${includedir}
  !addplugindir ${plugindir}
  !define JRE_VERSION "1.8"
  !define JRE_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=98426"
  !define JRE_URL_64 "http://javadl.sun.com/webapps/download/AutoDL?BundleId=98428"
  !include "JREDyna_Inetc.nsh"
 
;--------------------------------
;Configuration
 
  ;General
  Name "${AppName}"
Patrik Dufresne's avatar
Patrik Dufresne committed
  VIProductVersion "${AppVersion}"
  VIAddVersionKey "ProductName" "${AppName}"
  VIAddVersionKey "CompanyName" "${Vendor}"
  VIAddVersionKey "LegalCopyright" "(c) ${Vendor}"
  VIAddVersionKey "FileDescription" "${AppName} ${AppVersion} Installer"
  VIAddVersionKey "FileVersion" "${AppVersion}"
  OutFile "setup.exe"
 
  ;Folder selection page
Patrik Dufresne's avatar
Patrik Dufresne committed
  InstallDir "$PROGRAMFILES64\${ShortName}"

  ; Define icon
  !define MUI_ICON "planimod.ico"
  !define MUI_UNICON "planimod.ico"
 
  ;Get install folder from registry if available
  InstallDirRegKey HKLM "SOFTWARE\${Vendor}\${ShortName}" ""
Patrik Dufresne's avatar
Patrik Dufresne committed

  ;Request application privileges for Windows Vista
  RequestExecutionLevel admin
; Installation types
;InstType "full"	; Uncomment if you want Installation types

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

  ;Show all languages, despite user's codepage
  !define MUI_LANGDLL_ALLLANGUAGES

;--------------------------------
;Language Selection Dialog Settings

  ;Remember the installer language
  !define MUI_LANGDLL_REGISTRY_ROOT "HKCU" 
  !define MUI_LANGDLL_REGISTRY_KEY "SOFTWARE\${Vendor}\${ShortName}" 
  !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"

;--------------------------------
;Pages
 
  ; License page
  !insertmacro MUI_PAGE_LICENSE $(license)
Patrik Dufresne's avatar
Patrik Dufresne committed

  ; Java download page  
  !insertmacro CUSTOM_PAGE_JREINFO

  !insertmacro MUI_PAGE_INSTFILES
  !insertmacro MUI_PAGE_DIRECTORY
  !insertmacro MUI_PAGE_INSTFILES
  !insertmacro MUI_PAGE_FINISH
  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Modern UI Configuration
 
  !define MUI_ABORTWARNING
 
;--------------------------------
;Languages
 
  !insertmacro MUI_LANGUAGE "English"
  !insertmacro MUI_LANGUAGE "French"

  LicenseLangString license ${LANG_ENGLISH} "LICENSE.txt"
  LicenseLangString license ${LANG_FRENCH} "LICENSE.fr.txt"
  
  !insertmacro JREINFO_LANGUAGE
 
;--------------------------------
;Language Strings
 
  ;Description
  LangString DESC_SecAppFiles ${LANG_ENGLISH} "Application files copy"
  LangString DESC_SecAppFiles ${LANG_FRENCH} "Copie des fichiers"
 
;--------------------------------
;Reserve Files
Patrik Dufresne's avatar
Patrik Dufresne committed

 
;--------------------------------
;Installer Sections
 
Section "Installation of ${AppName}" SecAppFiles
  ; Remove files
  RMDir /r "$INSTDIR\lib"
  
  SectionIn 1 RO	; Full install, cannot be unselected
			; If you add more sections be sure to add them here as well
  ; Add files
  SetOutPath $INSTDIR
Patrik Dufresne's avatar
Patrik Dufresne committed
  SetOverwrite on
  File /r ".\"
  
  ;Store install folder
  WriteRegStr HKLM "SOFTWARE\${Vendor}\${ShortName}" "" $INSTDIR
 
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ShortName}" "DisplayName" "${AppName}"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ShortName}" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ShortName}" "NoModify" "1"
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ShortName}" "NoRepair" "1"
 
  ; Add application to firewall authorized list
Patrik Dufresne's avatar
Patrik Dufresne committed
  nsisFirewall::AddAuthorizedApplication "$INSTDIR\bin\planimod64.exe" "${AppName}"
  nsisFirewall::AddAuthorizedApplication "$INSTDIR\bin\planimod.exe" "${AppName}"
  !define REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ShortName}"
  WriteRegStr HKLM "${REG_UNINSTALL}" "DisplayName" "${AppName}"
  WriteRegStr HKLM "${REG_UNINSTALL}" "DisplayIcon" "$INSTDIR\minarca.ico"
  WriteRegStr HKLM "${REG_UNINSTALL}" "DisplayVersion" "${AppVersion}"
  WriteRegStr HKLM "${REG_UNINSTALL}" "Publisher" "${Vendor}"
  WriteRegStr HKLM "${REG_UNINSTALL}" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "${REG_UNINSTALL}" "NoModify" "1"
  WriteRegDWORD HKLM "${REG_UNINSTALL}" "NoRepair" "1"
 
  ;Create uninstaller
  WriteUninstaller "$INSTDIR\Uninstall.exe"
  
  ; Download and install java.
  call DownloadAndInstallJREIfNecessary
 
SectionEnd
 
 
Section "Start menu shortcuts" SecCreateShortcut
  ; Can be unselected
  SectionIn 1
  CreateDirectory "$SMPROGRAMS\${AppName}"
Patrik Dufresne's avatar
Patrik Dufresne committed
  ${If} ${RunningX64}
    CreateShortCut "$DESKTOP\${AppName}.lnk" "$INSTDIR\bin\planimod64.exe" "" "$INSTDIR\planimod.ico" 0
    CreateShortCut "$SMPROGRAMS\${AppName}\${AppName}.lnk" "$INSTDIR\bin\planimod64.exe" "" "$INSTDIR\planimod.ico" 0
  ${Else}
    CreateShortCut "$DESKTOP\${AppName}.lnk" "$INSTDIR\bin\planimod.exe" "" "$INSTDIR\planimod.ico" 0
    CreateShortCut "$SMPROGRAMS\${AppName}\${AppName}.lnk" "$INSTDIR\bin\planimod.exe" "" "$INSTDIR\planimod.ico" 0
  ${EndIf}
SectionEnd
 
;--------------------------------
;Descriptions
 
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecAppFiles} $(DESC_SecAppFiles)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
 
;--------------------------------
;Installer Functions
 
Function .onInit
Patrik Dufresne's avatar
Patrik Dufresne committed
  ; When running 64bits, read and write to 64bits registry.
  SetRegView 64
FunctionEnd
;--------------------------------
;Uninstaller Section
 
Section "Uninstall"
 
  ; remove registry keys
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ShortName}"
  DeleteRegKey HKLM  "SOFTWARE\${Vendor}\${AppName}"
  
  ; remove shortcuts, if any.
  Delete "$SMPROGRAMS\${AppName}\*.*"
  
  ; Remove application from the firewall authorized list
Patrik Dufresne's avatar
Patrik Dufresne committed
  nsisFirewall::RemoveAuthorizedApplication "$INSTDIR\bin\planimod64.exe" "${AppName}"
  nsisFirewall::RemoveAuthorizedApplication "$INSTDIR\bin\planimod.exe" "${AppName}"
  Pop $0
  
  ; remove files
  RMDir /r "$INSTDIR"
 
SectionEnd