2 # license GPL version 2
4 # file version 1.0 date 18-01-2007
6 ; To compile this script NSIS 2.23 and newer are required
7 ; http://nsis.sourceforge.net/
10 ; Do a Cyclic Redundancy Check to make sure the installer
11 ; was not corrupted by the download.
14 ; Make the installer as small as possible.
19 ; you only need to change this section for new releases
20 VIProductVersion "2.2.0.0" ; file version for the installer in the scheme "x.x.x.x"
24 Name "JabRef ${VERSION}"
25 !define REGKEY "SOFTWARE\JabRef"
26 !define COMPANY "JabRef Team"
27 !define URL "http://jabref.sourceforge.net"
28 !define PRODUCT_EXE "JabRef.exe"
29 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
30 !define PRODUCT_LICENSE_FILE "dist\gpl.txt"
42 !include "fileassoc.nsh"
43 !include "LogicLib.nsh"
47 !macro IsUserAdmin Result UName
54 UserInfo::GetAccountType
57 StrCpy ${Result} "yes"
64 StrCpy ${Result} "yes"
71 ; Remember the installer language
72 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
73 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
74 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
76 ; let warning appear when installation is canceled
77 !define MUI_ABORTWARNING
79 ; Icons for the installer program
80 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-full.ico"
81 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-full.ico"
84 !define MUI_WELCOMEPAGE_TEXT "$(WelcomePageText)"
85 !insertmacro MUI_PAGE_WELCOME
88 !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE_FILE}"
90 ; Specify the installation directory.
91 !insertmacro MUI_PAGE_DIRECTORY
93 ; choose the components to install.
94 !insertmacro MUI_PAGE_COMPONENTS
96 ; Specify where to install program shortcuts.
97 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
98 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
99 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
100 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "$(^Name)"
101 !insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} $StartmenuFolder
103 ; Watch the components being installed.
104 !insertmacro MUI_PAGE_INSTFILES
107 !define MUI_FINISHPAGE_RUN "$INSTDIR\${PRODUCT_EXE}"
108 !define MUI_FINISHPAGE_TEXT "$(FinishPageMessage)"
109 !define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageRun)"
110 !insertmacro MUI_PAGE_FINISH
113 !insertmacro MUI_UNPAGE_CONFIRM
114 !insertmacro MUI_UNPAGE_INSTFILES
117 # Installer languages
118 !insertmacro MUI_LANGUAGE "English" # first language is the default language
119 !insertmacro MUI_LANGUAGE "German"
120 !insertmacro MUI_LANGUAGE "French"
121 !insertmacro MUI_LANGUAGE "Italian"
123 !include "installer_languages\english.nsh"
124 !include "installer_languages\german.nsh"
125 !include "installer_languages\french.nsh"
126 !include "installer_languages\italian.nsh"
128 # Installer attributes
129 OutFile JabRefSetup.exe
130 InstallDir "$PROGRAMFILES\JabRef"
131 BrandingText "$(^Name) installer" ; appear at the bottom of the installer windows
132 XPStyle on ; use XP style for installer windows
133 InstallDirRegKey HKLM "${REGKEY}" Path
134 LicenseData "$(JabRefLicenseData)"
136 ; creates file informations for the JabRefSetup.exe
137 VIAddVersionKey ProductName "JabRef"
138 VIAddVersionKey ProductVersion "${VERSION}"
139 VIAddVersionKey CompanyName "${COMPANY}"
140 VIAddVersionKey CompanyWebsite "${URL}"
141 VIAddVersionKey FileDescription "JabRef installation program"
142 VIAddVersionKey LegalCopyright "under the GPL version 2"
143 VIAddVersionKey FileVersion ""
147 Section "!JabRef" SecCore
151 Section "$(SecAssociateBibTitle)" SecAssociateBib
152 !insertmacro APP_ASSOCIATE "bib" "JabRef.BibTeX" "$(FileTypeTitle)" "$INSTDIR\${PRODUCT_EXE},0" "$(OpenIn)" "$INSTDIR\${PRODUCT_EXE} $\"%1$\""
155 Section "$(SecDesktopTitle)" SecDesktop
156 StrCpy $CreateDesktopIcon "true"
159 ; section descriptions
160 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
161 !insertmacro MUI_DESCRIPTION_TEXT ${SecAssociateBib} "$(SecAssociateBibDescription)"
162 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
163 !insertmacro MUI_FUNCTION_DESCRIPTION_END
165 Section "-Installation actions" SecInstallation
167 ; create shortcuts for all users
168 SetShellVarContext all
170 SetOutPath "$INSTDIR"
173 WriteRegStr HKLM "${REGKEY}\Components" Main 1
175 WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
176 WriteUninstaller $INSTDIR\uninstall.exe
177 ; create shortcuts to startmenu
178 SetOutPath "$INSTDIR"
179 CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
180 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\$(^Name).lnk" "$INSTDIR\${PRODUCT_EXE}" "" "$INSTDIR\JabRef.exe"
181 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall $(^Name).lnk" "$INSTDIR\uninstall.exe"
182 ; create desktop icon
183 ${if} $CreateDesktopIcon == "true"
184 SetOutPath "$INSTDIR"
185 CreateShortCut "$DESKTOP\$(^Name).lnk" "$INSTDIR\${PRODUCT_EXE}" "" "$INSTDIR\${PRODUCT_EXE}" ;$(^Name).lnk
187 ; register information that appear in Windows' software listing
188 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
189 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${VERSION}"
190 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "Publisher" "${COMPANY}"
191 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${URL}"
192 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\${PRODUCT_EXE}"
193 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
194 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninstall.exe"
195 WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
196 WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
201 # Uninstaller sections
202 Section "un.JabRef" un.SecUnProgramFiles
205 ; delete installation folder
207 ; delete start menu entry
208 ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "StartMenu"
210 ; delete desktop icon
211 Delete "$DESKTOP\$(^Name).lnk"
212 ; delete registry entries
213 DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
214 DeleteRegKey HKLM "${PRODUCT_UNINST_KEY}"
215 DeleteRegKey HKCR "Applications\${PRODUCT_EXE}"
216 DeleteRegValue HKCR ".bib" "JabRef.BibTeX_backup"
217 DeleteRegValue HKLM "Software\Classes\.bib" "JabRef.BibTeX_backup"
218 DeleteRegKey HKLM "${REGKEY}"
219 ; remove file association with .bib-files
220 !insertmacro APP_UNASSOCIATE "bib" "JabRef.BibTeX"
221 ; close uninstaller automatically
227 # Installer functions
231 ; If the user does *not* have administrator privileges, abort
234 !insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
235 ${if} $Answer == "yes"
236 SetShellVarContext all ; set that e.g. shortcuts will be created for all users
238 MessageBox MB_OK|MB_ICONSTOP "$(NotAdmin)"
245 # Uninstaller functions
248 ; If the user does *not* have administrator privileges, abort
250 !insertmacro IsUserAdmin $Answer $UserName
251 ${if} $Answer == "yes"
252 SetShellVarContext all
254 MessageBox MB_OK|MB_ICONSTOP "$(UnNotAdminLabel)"
258 ; ask if it should really be removed
259 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" IDYES +2
264 Function un.onUninstSuccess
267 MessageBox MB_ICONINFORMATION|MB_OK "$(UnRemoveSuccessLabel)"