1
;==============================================================================================
2
;lenmus for Windows installer. NSIS v2.15 script for generating the exe installer and uninstaller
3
;Cecilio Salmeron <cecilio@lenmus.org>
5
; To generate a new version:
8
;==============================================================================================
10
;perform a CRC on the installer before allowing an install to make sure the installer
14
;set the compression algorithm to use (zlib | bzip2 | lzma)
17
;use the new XP controls style when running on Windows XP
20
;some helper defines and variables
21
!define APP_NAME "lenmus Phonascus"
22
!define APP_VERSION "3.0.b0"
23
!define APP_HOME_PAGE "http://www.lenmus.org/"
25
Name "lenmus v3.0 beta 0" ;product name displayed by the installer
28
;support for Modern UI
31
;support for GetParent
32
!include "FileFunc.nsh"
33
!insertmacro un.GetParent
35
;support to install fonts
36
!include "FontRegAdv.nsh"
37
!include "FontName.nsh"
39
;support to remove files and subdirs in one step
40
!include "RemoveFilesAndSubDirs.nsh"
44
;configuration settings for the MUI interface: options, icons, bitmaps, colors, etc.
45
;show a warning when the user cancels the install
46
!define MUI_ABORTWARNING
47
;icons to associate to the resulting installer and uninstaller
48
!define MUI_ICON "lenmus16c.ico"
49
!define MUI_UNICON "win-uninstall.ico"
51
!define MUI_HEADERIMAGE
52
!define MUI_HEADERIMAGE_BITMAP "BannerTop.bmp"
53
!define MUI_WELCOMEFINISHPAGE_BITMAP "BannerLeft.bmp"
54
!define MUI_COMPONENTSPAGE_SMALLDESC ;descriptions at bottom
56
;vars to create links on "Start Menu" folder
60
;var to store root install directory in uninstall section
64
;MUI: install pages to show
66
!insertmacro MUI_PAGE_WELCOME
68
;show and accept licence
69
!insertmacro MUI_PAGE_LICENSE $(license)
71
;choose installation directory
72
!insertmacro MUI_PAGE_DIRECTORY
74
;select optional components
75
!define MUI_COMPONENTSPAGE_TEXT_COMPLIST $(MSG_OptionalComponents)
76
!insertmacro MUI_PAGE_COMPONENTS
78
;ask about creating links on Start Menu
79
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
80
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\LenMus"
81
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartMenuFolder"
82
!define MUI_STARTMENUPAGE_DEFAULTFOLDER $(SM_PRODUCT_GROUP)
83
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
86
!insertmacro MUI_PAGE_INSTFILES
88
;finish page: run installed program?
89
!define MUI_FINISHPAGE_RUN "$INSTDIR\bin\lenmus.exe"
90
!insertmacro MUI_PAGE_FINISH
94
;ask for confirmation to uninstall
95
!insertmacro MUI_UNPAGE_CONFIRM
98
!insertmacro MUI_UNPAGE_INSTFILES
102
;language selection dialog settings
103
;Remember the installer language
104
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
105
!define MUI_LANGDLL_REGISTRY_KEY "Software\LenMus"
106
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
109
!insertmacro MUI_LANGUAGE "Spanish"
110
!insertmacro MUI_LANGUAGE "English"
112
;reserve files for languages
113
;These files should be inserted before other files in the data block
114
;Keep these lines before any File command
115
!insertmacro MUI_RESERVEFILE_LANGDLL
119
;define filename of installer and uninstaller
120
!define INSTALLER_NAME "lenmus_${APP_VERSION}.exe"
121
!define UNINSTALLER_NAME "uninstall_lenmus.exe"
123
;variable to retry installation when error found
127
;Specify path and name of resulting installer
128
OutFile "${INSTALLER_NAME}"
130
;define the default installation directory
131
InstallDir "$PROGRAMFILES\LenMus"
133
;Registry key to check for directory, so if you install again, it will take the old one
134
;as default installation directory instead of the previously defined.
135
InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\lenmus.exe" ""
137
;instruct installer and uninstaller to show install/uninstall log to the user
138
ShowInstDetails show ;show install log
139
ShowUnInstDetails show ;show uninstall log
142
;languaje files to support different languages <---- Est� comentado durante el desarrollo.
144
;!include "lenmus_spanish.nsh"
145
;!include "lenmus_english.nsh"
147
; Este trozo s�lo durante el desarrollo. Luego cortar, llevar a
148
; "lenmus_Spanish.nsh" y quitar los comentarios de las dos sentencias anteriores
149
;========================================================================================
151
;Spanish language file for lenmus installer/uninstaller
152
;---------------------------------------------------------------------------------------------------------
154
LicenseLangString license ${LANG_Spanish} "license_spa.rtf"
156
;strings to customize MUI pages
157
LangString MSG_OptionalComponents ${LANG_Spanish} "Por favor, seleccione los componentes opcionales que desee instalar"
160
;section titles, what user sees to select components for installation
161
LangString TITLE_CreateIcon ${LANG_Spanish} "Acceso directo en escritorio"
162
LangString TITLE_Scores ${LANG_Spanish} "Partituras de ejemplo"
163
LangString TITLE_RegKeys ${LANG_Spanish} "Incluir en panel de control (en 'Agregar/quitar software')"
165
;descriptions for the sections. Displayed to user when mouse hovers over a section
166
LangString DESC_CreateIcon ${LANG_Spanish} "Crear un icono de acceso directo en el escritorio"
167
LangString DESC_Scores ${LANG_Spanish} "Crear una carpeta con algunas partituras de ejemplo"
168
LangString DESC_RegKeys ${LANG_Spanish} "Crear claves en el Registro de Windows para que el LenMus aparezca en panel de control, en 'Agregar/quitar programas'"
171
;error messages and other texts
172
LangString ERROR_CopyFiles ${LANG_Spanish} "Error copiando archivos de programa"
173
LangString ERROR_InstallFonts ${LANG_Spanish} "Error instalando el font"
174
LangString ERROR_CreateIcon ${LANG_Spanish} "Error creando acceso directo en el escritorio"
175
LangString ERROR_CopyScores ${LANG_Spanish} "Error copiando partituras de ejemplo"
176
LangString ERROR_DeterminarOS ${LANG_Spanish} "Error al tratar de determinar cual es el sistema operativo"
177
LangString MSG_CONTINUE ${LANG_Spanish} "�Quiere continuar instalando?"
178
LangString MSG_ABORT ${LANG_Spanish} "Instalaci�n cancelada"
181
;start menu & desktop descriptions
182
LangString SM_PRODUCT_GROUP ${LANG_Spanish} "${APP_NAME}"
183
LangString SHORTCUT_NAME_EXEC ${LANG_Spanish} "Ejecutar ${APP_NAME}"
184
LangString SHORTCUT_NAME_UNINSTALL ${LANG_Spanish} "Desinstalar ${APP_NAME}"
186
;End Spanish language file
187
;=========================================================================================
189
;English language file for lenmus installer/uninstaller
190
;---------------------------------------------------------------------------------------------------------
192
LicenseLangString license ${LANG_English} "license_eng.rtf"
194
;strings to customize MUI pages
195
LangString MSG_OptionalComponents ${LANG_English} "Please, choose the optional components you would like to install"
198
;section titles, what user sees to select components for installation
199
LangString TITLE_CreateIcon ${LANG_English} "Shorcut on desktop"
200
LangString TITLE_Scores ${LANG_English} "Examples of music scores"
201
LangString TITLE_RegKeys ${LANG_English} "Add to Control Panel (to 'Add/Remove Programs')"
203
;descriptions for the sections. Displayed to user when mouse hovers over a section
204
LangString DESC_CreateIcon ${LANG_English} "Create a shorcut icon on the desktop"
205
LangString DESC_Scores ${LANG_English} "Create a folder containing some examples of music scores"
206
LangString DESC_RegKeys ${LANG_English} "Create keys in Windows Registry to add LenMus to the 'Add/Remove Programs' section in the Control Panel."
209
;error messages and other texts
210
LangString ERROR_CopyFiles ${LANG_English} "Error copying program files"
211
LangString ERROR_InstallFonts ${LANG_English} "Error installing font"
212
LangString ERROR_CreateIcon ${LANG_English} "Error creating shortcut on desktop"
213
LangString ERROR_CopyScores ${LANG_English} "Error copying examples of music scores"
214
LangString ERROR_DeterminarOS ${LANG_English} "Error trying to identify operting system"
215
LangString MSG_CONTINUE ${LANG_English} "Would you like to continue the installation?"
216
LangString MSG_ABORT ${LANG_English} "Installation canceled"
219
;start menu & desktop descriptions
220
LangString SM_PRODUCT_GROUP ${LANG_English} "${APP_NAME}"
221
LangString SHORTCUT_NAME_EXEC ${LANG_English} "Run ${APP_NAME}"
222
LangString SHORTCUT_NAME_UNINSTALL ${LANG_English} "Uninstall ${APP_NAME}"
224
;End English language file
225
;=========================================================================================
230
; *********************************************************************
232
; *********************************************************************
234
;first of all, show installer language selection page
236
!insertmacro MUI_LANGDLL_DISPLAY
240
;Install all the mandatory components
241
Section "-" "SeccionBasica"
243
; vars initialization
246
;If a previous version exits delete old installed files, but no scores
247
;-----------------------------------------------------------------------------------
248
!insertmacro RemoveFilesAndSubDirs "$INSTDIR\bin"
249
!insertmacro RemoveFilesAndSubDirs "$INSTDIR\locale"
250
!insertmacro RemoveFilesAndSubDirs "$INSTDIR\res"
251
!insertmacro RemoveFilesAndSubDirs "$INSTDIR\xrc"
252
!insertmacro RemoveFilesAndSubDirs "$INSTDIR\temp"
255
;install application files
256
;-----------------------------------------------------------------------------------
260
SetOutPath "$INSTDIR"
261
File "..\..\docs\html\licence.htm"
262
File "..\..\docs\html\singledoc.css"
263
File "..\..\docs\release\licence.txt"
264
File "license_eng.rtf"
265
File "license_spa.rtf"
267
SetOutPath "$INSTDIR\bin"
268
File "..\..\z_bin\lenmus.exe"
269
File "..\..\fonts\LeMusNot.ttf"
271
SetOutPath "$INSTDIR\locale\en"
272
File "..\..\locale\en\*.*"
273
SetOutPath "$INSTDIR\locale\es"
274
File "..\..\locale\es\*.*"
276
SetOutPath "$INSTDIR\res\bitmaps"
277
File "..\..\res\bitmaps\*.*"
278
SetOutPath "$INSTDIR\res\icons"
279
File "..\..\res\icons\*.*"
281
SetOutPath "$INSTDIR\xrc"
282
File "..\..\xrc\*.xrc"
284
SetOutPath "$INSTDIR\temp"
285
File "..\..\temp\DataError.log"
287
IfErrors +1 EndCopyFiles
288
StrCmp $STEP "ErrorCopyingFiles" "Error_CopyFiles"
289
StrCpy "$STEP" "ErrorCopyingFiles"
292
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(ERROR_CopyFiles) IDRETRY CopyFiles
293
MessageBox MB_YESNO|MB_ICONQUESTION $(MSG_CONTINUE) IDYES +2
299
;-----------------------------------------------------------------------------------
302
StrCpy $FONT_DIR $FONTS
303
!insertmacro InstallTTF '..\..\fonts\LeMusNot.ttf'
304
SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0 /TIMEOUT=5000
305
IfErrors +1 EndInstallFonts
306
StrCmp $STEP "ErrorInstallingFonts" "Error_InstallFonts"
307
StrCpy "$STEP" "ErrorInstallingFonts"
310
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(ERROR_InstallFonts) IDRETRY InstallFonts
311
MessageBox MB_YESNO|MB_ICONQUESTION $(MSG_CONTINUE) IDYES +2
315
;create entries in Start Menu folder
316
;-----------------------------------------------------------------------------------
317
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
318
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
319
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\$(SHORTCUT_NAME_EXEC).lnk" "$INSTDIR\bin\lenmus.exe"
320
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\$(SHORTCUT_NAME_UNINSTALL).lnk" "$INSTDIR\bin\${UNINSTALLER_NAME}"
321
!insertmacro MUI_STARTMENU_WRITE_END
324
WriteUninstaller "$INSTDIR\bin\${UNINSTALLER_NAME}"
328
;===============================================================================================================
329
; Installation of optional components
330
;===============================================================================================================
332
;-----------------------------------------------------------------------------------------------
333
; shortcut icon on desktop
334
;-----------------------------------------------------------------------------------------------
335
Section $(TITLE_CreateIcon) CreateIcon
339
CreateShortCut "$DESKTOP\lenmus.lnk" "$INSTDIR\bin\lenmus.exe"
340
IfErrors +1 EndCreateIcon
341
StrCmp $STEP "ErrorCreatingIcon" "Error_CreateIcon"
342
StrCpy "$STEP" "ErrorCreatingIcon"
345
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(ERROR_CreateIcon) IDRETRY CreateIcon
346
MessageBox MB_YESNO|MB_ICONQUESTION $(MSG_CONTINUE) IDYES +2
352
;-----------------------------------------------------------------------------------------------
353
; example score sheets
354
;-----------------------------------------------------------------------------------------------
355
Section $(TITLE_Scores) Scores
360
SetOutPath "$INSTDIR\scores\MusicXML"
361
File "..\..\scores\MusicXML\*.*"
362
SetOutPath "$INSTDIR\scores\test"
363
File "..\..\scores\test\*.*"
364
IfErrors +1 EndCopyScores
365
StrCmp $STEP "ErrorCopyingScores" "Error_CopyScores"
366
StrCpy "$STEP" "ErrorCopyingScores"
369
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(ERROR_CopyScores) IDRETRY CopyScores
370
MessageBox MB_YESNO|MB_ICONQUESTION $(MSG_CONTINUE) IDYES +2
376
;-----------------------------------------------------------------------------------------------
377
; Add uninstall information to Add/Remove Programs so that lenmus program
378
; will be included on the "Add/Remove Programs" folder of the Control Pannel
379
;-----------------------------------------------------------------------------------------------
380
Section $(TITLE_RegKeys) RegKeys
382
; mandatory keys for un-installing
383
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LenMus" "DisplayName" "$(^Name)"
384
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LenMus" "UninstallString" "$INSTDIR\bin\${UNINSTALLER_NAME}"
386
; optional information
388
;NoModify (DWORD) - 1 if uninstaller has no option to modify the installed application
389
;NoRepair (DWORD) - 1 if the uninstaller has no option to repair the installation
390
WriteRegDWord HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LenMus" "NoModifiy" 1
391
WriteRegDWord HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LenMus" "NoRepair" 1
396
;assign descriptions to sections -------------------------------------------------------
398
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
399
!insertmacro MUI_DESCRIPTION_TEXT ${CreateIcon} $(DESC_CreateIcon)
400
!insertmacro MUI_DESCRIPTION_TEXT ${Scores} $(DESC_Scores)
401
!insertmacro MUI_DESCRIPTION_TEXT ${RegKeys} $(DESC_RegKeys)
402
!insertmacro MUI_FUNCTION_DESCRIPTION_END
407
############################################################################################
409
############################################################################################
411
;get the stored language preference
413
!insertmacro MUI_UNGETLANGUAGE
418
FindWindow $R0 "THMNISEdit2_MainWindowClass"
420
MessageBox MB_ICONEXCLAMATION|MB_OK "lenmus est� ejecut�ndose. Antes de desinstalar lenmus debe cerrarlo."
423
UserInfo::GetAccountType
425
StrCmp $R0 "Admin" 0 +2
426
SetShellVarContext all
431
;the font will not be uninstalled as it might have been used by other applications
433
; move to root directory and delete all folders and files
434
${un.GetParent} "$INSTDIR" $LENMUS_DIR
435
!insertmacro RemoveFilesAndSubDirs "$LENMUS_DIR"
438
;Delete "$INSTDIR\*.*"
439
;Delete "$INSTDIR\bin\*.*"
440
;Delete "$INSTDIR\locale\en\*.*"
441
;Delete "$INSTDIR\locale\es\*.*"
442
;Delete "$INSTDIR\res\bitmaps\*.*"
443
;Delete "$INSTDIR\res\icons\*.*"
444
;Delete "$INSTDIR\xrc\*.*"
445
;Delete "$INSTDIR\temp\*.*"
446
;Delete "$INSTDIR\scores\MusicXML\*.*"
447
;Delete "$INSTDIR\scores\test\*.*"
450
;RMDir "$INSTDIR\bin"
451
;RMDir "$INSTDIR\locale\en"
452
;RMDir "$INSTDIR\locale\es"
453
;RMDir "$INSTDIR\locale"
454
;RMDir "$INSTDIR\res\bitmaps"
455
;RMDir "$INSTDIR\res\icons"
456
;RMDir "$INSTDIR\res"
457
;RMDir "$INSTDIR\xrc"
458
;RMDir "$INSTDIR\temp"
459
;RMDir "$INSTDIR\scores\MusicXML"
460
;RMDir "$INSTDIR\scores\test"
461
;RMDir "$INSTDIR\scores"
464
;delete ico on desktop
465
Delete "$DESKTOP\lenmus.lnk"
467
;delete Start Menu folder entries
468
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
469
Delete "$SMPROGRAMS\$MUI_TEMP\*.*"
470
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
472
DeleteRegKey /ifempty HKCU "Software\LenMus"
475
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LenMus"
476
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\lenmus.exe"
482
;End of lenmus install/uninstall script