2 # license GPL version 2
4 # file version 2.0 date 20-11-2007
6 ; To compile this script NSIS 2.30 or 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.
17 ; set execution level for Windows Vista
18 RequestExecutionLevel user
21 ; you only need to change this section for new releases
22 ; you only need to change this section for new releases
23 VIProductVersion "2.4.0.0" ; file version for the installer in the scheme "x.x.x.x"
27 Name "JabRef ${VERSION}"
28 !define REGKEY "SOFTWARE\JabRef"
29 !define COMPANY "JabRef Team"
30 !define URL "http://jabref.sourceforge.net"
31 !define PRODUCT_NAME "JabRef"
32 !define PRODUCT_EXE "$INSTDIR\JabRef.exe"
33 !define PRODUCT_EXE2 "JabRef.exe"
34 !define PRODUCT_REGNAME "BibTeX.Document"
35 !define PRODUCT_EXT ".bib"
36 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
37 !define PRODUCT_LICENSE_FILE "dist\gpl.txt"
40 ; registry preparations
41 !define SHCNE_ASSOCCHANGED 0x08000000
42 !define SHCNF_IDLIST 0
47 Var CreateFileAssociations
55 !include "LogicLib.nsh"
59 !macro IsUserAdmin Result UName
66 UserInfo::GetAccountType
69 StrCpy ${Result} "yes"
76 StrCpy ${Result} "yes"
83 ; Remember the installer language
84 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
85 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
86 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
88 ; let warning appear when installation is canceled
89 !define MUI_ABORTWARNING
91 ; Icons for the installer program
92 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-full.ico"
93 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-full.ico"
96 !define MUI_WELCOMEPAGE_TEXT "$(WelcomePageText)"
97 !insertmacro MUI_PAGE_WELCOME
100 !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE_FILE}"
102 ; Specify the installation directory.
103 !insertmacro MUI_PAGE_DIRECTORY
105 ; choose the components to install.
106 !insertmacro MUI_PAGE_COMPONENTS
108 ; Specify where to install program shortcuts.
109 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
110 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
111 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
112 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "$(^Name)"
113 !insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} $StartmenuFolder
115 ; Watch the components being installed.
116 !insertmacro MUI_PAGE_INSTFILES
119 !define MUI_FINISHPAGE_RUN "${PRODUCT_EXE}"
120 !define MUI_FINISHPAGE_TEXT "$(FinishPageMessage)"
121 !define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageRun)"
122 !insertmacro MUI_PAGE_FINISH
125 !insertmacro MUI_UNPAGE_CONFIRM
126 !insertmacro MUI_UNPAGE_INSTFILES
129 # Installer languages
130 !insertmacro MUI_LANGUAGE "English" # first language is the default language
131 !insertmacro MUI_LANGUAGE "German"
133 !include "installer_languages\english.nsh"
134 !include "installer_languages\german.nsh"
137 # Installer attributes
138 OutFile JabRefSetup.exe
139 InstallDir "$PROGRAMFILES\JabRef"
140 BrandingText "$(^Name) installer" ; appear at the bottom of the installer windows
141 XPStyle on ; use XP style for installer windows
142 LicenseData "$(JabRefLicenseData)"
144 ; creates file informations for the JabRefSetup.exe
145 VIAddVersionKey ProductName "JabRef"
146 VIAddVersionKey ProductVersion "${VERSION}"
147 VIAddVersionKey CompanyName "${COMPANY}"
148 VIAddVersionKey CompanyWebsite "${URL}"
149 VIAddVersionKey FileDescription "JabRef installation program"
150 VIAddVersionKey LegalCopyright "under the GPL version 2"
151 VIAddVersionKey FileVersion ""
155 Section "!JabRef" SecCore
159 Section "$(SecAssociateBibTitle)" SecAssociateBib
160 StrCpy $CreateFileAssociations "true"
163 Section "$(SecDesktopTitle)" SecDesktop
164 StrCpy $CreateDesktopIcon "true"
167 ; section descriptions
168 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
169 !insertmacro MUI_DESCRIPTION_TEXT ${SecAssociateBib} "$(SecAssociateBibDescription)"
170 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
171 !insertmacro MUI_FUNCTION_DESCRIPTION_END
173 Section "-Installation actions" SecInstallation
176 SetOutPath "$INSTDIR"
179 WriteRegStr SHCTX "${REGKEY}\Components" Main 1
182 WriteRegStr SHCTX "${REGKEY}" Path $INSTDIR
183 WriteUninstaller $INSTDIR\uninstall.exe
185 ; create shortcuts to startmenu
186 SetOutPath "$INSTDIR"
187 CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
188 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\$(^Name).lnk" "${PRODUCT_EXE}" "" "$INSTDIR\JabRef.exe"
189 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall $(^Name).lnk" "$INSTDIR\uninstall.exe"
191 ; create desktop icon
192 ${if} $CreateDesktopIcon == "true"
193 SetOutPath "$INSTDIR"
194 CreateShortCut "$DESKTOP\$(^Name).lnk" "${PRODUCT_EXE}" "" "${PRODUCT_EXE}" ;$(^Name).lnk
196 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
197 ${if} $Answer == "yes" ; if user is admin
199 ; register information that appear in Windows' software listing
200 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
201 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${VERSION}"
202 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Publisher" "${COMPANY}"
203 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${URL}"
204 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "${PRODUCT_EXE}"
205 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninstall.exe"
206 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
207 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
210 # register the extension .bib
211 ${if} $CreateFileAssociations == "true"
212 # write informations about file type
213 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}" "" "${PRODUCT_NAME} Document"
214 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\DefaultIcon" "" "${PRODUCT_EXE},0"
215 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\Shell\open\command" "" '"${PRODUCT_EXE}" "%1"'
216 # write informations about file extensions
217 WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "" "${PRODUCT_REGNAME}"
219 System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
225 # Uninstaller sections
226 Section "un.JabRef" un.SecUnProgramFiles
229 ; delete installation folder
231 ; delete start menu entry
232 ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu"
235 ; delete desktop icon
236 Delete "$DESKTOP\$(^Name).lnk"
238 # remove file extension
239 ReadRegStr $R0 SHCTX "Software\Classes\${PRODUCT_EXT}" ""
240 ${if} $R0 == "${PRODUCT_REGNAME}"
241 DeleteRegKey SHCTX "Software\Classes\${PRODUCT_EXT}"
242 DeleteRegKey SHCTX "Software\Classes\${PRODUCT_REGNAME}"
245 ; delete remaining registry entries
246 DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
247 DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
248 DeleteRegKey HKCR "Applications\${PRODUCT_EXE2}"
249 DeleteRegKey HKCU "${REGKEY}"
250 DeleteRegKey SHCTX "${REGKEY}"
252 ; close uninstaller automatically
258 # Installer functions
261 StrCpy $StartmenuFolder ${PRODUCT_NAME}
263 # check if the same Jabref version is already installed
264 ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY}" "Publisher"
266 MessageBox MB_OK|MB_ICONSTOP "$(StillInstalled)" /SD IDOK
271 ; If the user does *not* have administrator privileges, abort
274 !insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
275 ${if} $Answer == "yes"
276 SetShellVarContext all ; set that e.g. shortcuts will be created for all users
278 SetShellVarContext current
279 StrCpy $INSTDIR "$APPDATA\$(^Name)"
285 # Uninstaller functions
288 ; If the user does *not* have administrator privileges, abort
290 !insertmacro IsUserAdmin $Answer $UserName
291 ${if} $Answer == "yes"
292 SetShellVarContext all
294 # check if the Jabref has been installed with admin permisions
295 ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
297 MessageBox MB_OK|MB_ICONSTOP "$(UnNotAdminLabel)" /SD IDOK
300 SetShellVarContext current
303 ; ask if it should really be removed
304 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" /SD IDYES IDYES +2
309 Function un.onUninstSuccess
312 MessageBox MB_ICONINFORMATION|MB_OK "$(UnRemoveSuccessLabel)" /SD IDOK