Some improvements to the deployment script.
[LameXP.git] / etc / NSIS / setup.nsi
blob5cc23570aef913e9b79549aa713c6b1ad8d47649
1 ; ///////////////////////////////////////////////////////////////////////////////
2 ; // LameXP - Audio Encoder Front-End
3 ; // Copyright (C) 2004-2018 LoRd_MuldeR <MuldeR2@GMX.de>
4 ; //
5 ; // This program is free software; you can redistribute it and/or modify
6 ; // it under the terms of the GNU General Public License as published by
7 ; // the Free Software Foundation; either version 2 of the License, or
8 ; // (at your option) any later version.
9 ; //
10 ; // This program is distributed in the hope that it will be useful,
11 ; // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ; // GNU General Public License for more details.
14 ; //
15 ; // You should have received a copy of the GNU General Public License along
16 ; // with this program; if not, write to the Free Software Foundation, Inc.,
17 ; // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 ; //
19 ; // http://www.gnu.org/licenses/gpl-2.0.txt
20 ; ///////////////////////////////////////////////////////////////////////////////
23 ;--------------------------------
24 ;Basic Defines
25 ;--------------------------------
27 !ifndef NSIS_UNICODE
28 !error "NSIS_UNICODE is undefined, please compile with Unicode NSIS !!!"
29 !endif
31 !ifndef LAMEXP_VERSION
32 !error "LAMEXP_VERSION is not defined !!!"
33 !endif
34 !ifndef LAMEXP_BUILD
35 !error "LAMEXP_BUILD is not defined !!!"
36 !endif
37 !ifndef LAMEXP_INSTTYPE
38 !error "LAMEXP_INSTTYPE is not defined !!!"
39 !endif
40 !ifndef LAMEXP_PATCH
41 !error "LAMEXP_PATCH is not defined !!!"
42 !endif
43 !ifndef LAMEXP_DATE
44 !error "LAMEXP_DATE is not defined !!!"
45 !endif
46 !ifndef LAMEXP_OUTPUT_FILE
47 !error "LAMEXP_OUTPUT_FILE is not defined !!!"
48 !endif
49 !ifndef LAMEXP_SOURCE_PATH
50 !error "LAMEXP_SOURCE_PATH is not defined !!!"
51 !endif
53 ;UUID
54 !define MyRegPath "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{FBD7A67D-D700-4043-B54F-DD106D00F308}"
56 ;App Paths
57 !define AppPaths "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"
59 ;Web-Site
60 !define MyWebSite "http://muldersoft.com/"
63 ;--------------------------------
64 ;Check for Pre-Release
65 ;--------------------------------
67 !define LAMEXP_IS_PRERELEASE
69 !if '${LAMEXP_INSTTYPE}' == 'Final'
70 !undef LAMEXP_IS_PRERELEASE
71 !endif
72 !if '${LAMEXP_INSTTYPE}' == 'Hotfix'
73 !undef LAMEXP_IS_PRERELEASE
74 !endif
77 ;--------------------------------
78 ;Manifest
79 ;--------------------------------
81 !tempfile PACKHDRTEMP
82 !packhdr "${PACKHDRTEMP}" '"..\..\..\Prerequisites\MSVC\redist\bin\mt.exe" -manifest "setup.manifest" -outputresource:"${PACKHDRTEMP};1" && "..\..\..\Prerequisites\UPX\upx.exe" --brute "${PACKHDRTEMP}"'
85 ;--------------------------------
86 ;Includes
87 ;--------------------------------
89 !include `MUI2.nsh`
90 !include `WinVer.nsh`
91 !include `x64.nsh`
92 !include `StdUtils.nsh`
95 ;--------------------------------
96 ;Installer Attributes
97 ;--------------------------------
99 RequestExecutionLevel admin
100 ShowInstDetails show
101 ShowUninstDetails show
102 Name "LameXP v${LAMEXP_VERSION} ${LAMEXP_INSTTYPE}-${LAMEXP_PATCH} [Build #${LAMEXP_BUILD}]"
103 OutFile "${LAMEXP_OUTPUT_FILE}"
104 BrandingText "Date created: ${LAMEXP_DATE} [Build #${LAMEXP_BUILD}]"
105 InstallDir "$PROGRAMFILES\MuldeR\LameXP"
106 InstallDirRegKey HKLM "${MyRegPath}" "InstallLocation"
109 ;--------------------------------
110 ;Compressor
111 ;--------------------------------
113 SetCompressor /SOLID LZMA
114 SetCompressorDictSize 64
117 ;--------------------------------
118 ;Reserved Files
119 ;--------------------------------
121 ReserveFile "${NSISDIR}\Plugins\Aero.dll"
122 ReserveFile "${NSISDIR}\Plugins\LangDLL.dll"
123 ReserveFile "${NSISDIR}\Plugins\LockedList.dll"
124 ReserveFile "${NSISDIR}\Plugins\LockedList64.dll"
125 ReserveFile "${NSISDIR}\Plugins\nsDialogs.dll"
126 ReserveFile "${NSISDIR}\Plugins\nsExec.dll"
127 ReserveFile "${NSISDIR}\Plugins\StartMenu.dll"
128 ReserveFile "${NSISDIR}\Plugins\StdUtils.dll"
129 ReserveFile "${NSISDIR}\Plugins\System.dll"
130 ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
133 ;--------------------------------
134 ;Variables
135 ;--------------------------------
137 Var StartMenuFolder
140 ;--------------------------------
141 ;Version Info
142 ;--------------------------------
144 !searchreplace PRODUCT_VERSION_DATE "${LAMEXP_DATE}" "-" "."
145 VIProductVersion "${PRODUCT_VERSION_DATE}.${LAMEXP_BUILD}"
147 VIAddVersionKey "Author" "LoRd_MuldeR <mulder2@gmx.de>"
148 VIAddVersionKey "Comments" "This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version."
149 VIAddVersionKey "CompanyName" "Free Software Foundation"
150 VIAddVersionKey "FileDescription" "LameXP v${LAMEXP_VERSION} ${LAMEXP_INSTTYPE}-${LAMEXP_PATCH} [Build #${LAMEXP_BUILD}]"
151 VIAddVersionKey "FileVersion" "${PRODUCT_VERSION_DATE}.${LAMEXP_BUILD} (${LAMEXP_VERSION})"
152 VIAddVersionKey "LegalCopyright" "Copyright 2004-2018 LoRd_MuldeR"
153 VIAddVersionKey "LegalTrademarks" "GNU"
154 VIAddVersionKey "OriginalFilename" "LameXP.${LAMEXP_DATE}.exe"
155 VIAddVersionKey "ProductName" "LameXP - Audio Encoder Frontend"
156 VIAddVersionKey "ProductVersion" "${LAMEXP_VERSION}, Build #${LAMEXP_BUILD} (${LAMEXP_DATE})"
157 VIAddVersionKey "Website" "${MyWebSite}"
160 ;--------------------------------
161 ;MUI2 Interface Settings
162 ;--------------------------------
164 !define MUI_ABORTWARNING
165 !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
166 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${MyRegPath}"
167 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartmenuFolder"
168 !define MUI_LANGDLL_REGISTRY_ROOT HKLM
169 !define MUI_LANGDLL_REGISTRY_KEY "${MyRegPath}"
170 !define MUI_LANGDLL_REGISTRY_VALUENAME "SetupLanguage"
171 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "LameXP v${LAMEXP_VERSION}"
172 !define MUI_FINISHPAGE_NOAUTOCLOSE
173 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
174 !define MUI_FINISHPAGE_RUN
175 !define MUI_FINISHPAGE_RUN_FUNCTION RunAppFunction
176 !define MUI_FINISHPAGE_SHOWREADME
177 !define MUI_FINISHPAGE_SHOWREADME_FUNCTION ShowReadmeFunction
178 !define MUI_FINISHPAGE_LINK ${MyWebSite}
179 !define MUI_FINISHPAGE_LINK_LOCATION ${MyWebSite}
180 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
181 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"
182 !define MUI_WELCOMEFINISHPAGE_BITMAP "wizard.bmp"
183 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "wizard-un.bmp"
184 !define MUI_HEADERIMAGE
185 !define MUI_HEADERIMAGE_BITMAP "header.bmp"
186 !define MUI_HEADERIMAGE_UNBITMAP "header-un.bmp"
187 !define MUI_LANGDLL_ALLLANGUAGES
188 !define MUI_CUSTOMFUNCTION_GUIINIT MyGuiInit
189 !define MUI_CUSTOMFUNCTION_UNGUIINIT un.MyGuiInit
190 !define MUI_LANGDLL_ALWAYSSHOW
193 ;--------------------------------
194 ;MUI2 Pages (Installer)
195 ;--------------------------------
197 ;Welcome
198 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
199 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE CheckForPreRelease
200 !define MUI_WELCOMEPAGE_TITLE_3LINES
201 !define MUI_FINISHPAGE_TITLE_3LINES
202 !insertmacro MUI_PAGE_WELCOME
204 ;License
205 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
206 !insertmacro MUI_PAGE_LICENSE "license.rtf"
208 ;Directory
209 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
210 !define MUI_PAGE_CUSTOMFUNCTION_SHOW CheckForUpdate
211 !insertmacro MUI_PAGE_DIRECTORY
213 ;Startmenu
214 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
215 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
217 ;LockedList
218 Page Custom LockedListShow
220 ;Install Files
221 !insertmacro MUI_PAGE_INSTFILES
223 ;Finish
224 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
225 !insertmacro MUI_PAGE_FINISH
228 ;--------------------------------
229 ;MUI2 Pages (Uninstaller)
230 ;--------------------------------
232 ;Welcome
233 !define MUI_WELCOMEPAGE_TITLE_3LINES
234 !define MUI_FINISHPAGE_TITLE_3LINES
235 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
236 !insertmacro MUI_UNPAGE_WELCOME
238 ;Confirm
239 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
240 !insertmacro MUI_UNPAGE_CONFIRM
242 ;LockedList
243 UninstPage Custom un.LockedListShow
245 ;Uninstall
246 !insertmacro MUI_UNPAGE_INSTFILES
248 ;Finish
249 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
250 !insertmacro MUI_UNPAGE_FINISH
253 ;--------------------------------
254 ;Languages
255 ;--------------------------------
257 !insertmacro MUI_LANGUAGE "English" ;first language is the default language
258 !insertmacro MUI_LANGUAGE "German"
259 !insertmacro MUI_LANGUAGE "Spanish"
260 !insertmacro MUI_LANGUAGE "Russian"
261 !insertmacro MUI_LANGUAGE "Ukrainian"
262 !insertmacro MUI_LANGUAGE "Polish"
263 !insertmacro MUI_LANGUAGE "Hungarian"
265 ; !insertmacro MUI_LANGUAGE "French"
266 ; !insertmacro MUI_LANGUAGE "SpanishInternational"
267 ; !insertmacro MUI_LANGUAGE "SimpChinese"
268 ; !insertmacro MUI_LANGUAGE "TradChinese"
269 ; !insertmacro MUI_LANGUAGE "Japanese"
270 ; !insertmacro MUI_LANGUAGE "Italian"
271 ; !insertmacro MUI_LANGUAGE "Dutch"
272 ; !insertmacro MUI_LANGUAGE "Greek"
273 ; !insertmacro MUI_LANGUAGE "Romanian"
274 ; !insertmacro MUI_LANGUAGE "Serbian"
275 ; !insertmacro MUI_LANGUAGE "SerbianLatin"
276 ; !insertmacro MUI_LANGUAGE "Arabic"
277 ; !insertmacro MUI_LANGUAGE "Portuguese"
278 ; !insertmacro MUI_LANGUAGE "Afrikaans"
279 ; !insertmacro MUI_LANGUAGE "Malay"
280 ; !insertmacro MUI_LANGUAGE "Indonesian"
283 ;--------------------------------
284 ;Translation
285 ;--------------------------------
287 ;English
288 !include "..\Translation\Blank.nsh"
290 ;German
291 !include "..\Translation\LameXP_DE.nsh"
293 ;Spanish
294 !include "..\Translation\LameXP_ES.nsh"
296 ;Russian
297 !include "..\Translation\LameXP_RU.nsh"
299 ;Ukrainian
300 !include "..\Translation\LameXP_UK.nsh"
302 ;Polish
303 !include "..\Translation\LameXP_PL.nsh"
305 ;Hungarian
306 !include "..\Translation\LameXP_HU.nsh"
309 ;--------------------------------
310 ;LogicLib Extensions
311 ;--------------------------------
313 !macro _UnattendedMode _a _b _t _f
314 !insertmacro _LOGICLIB_TEMP
315 ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Update"
316 StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
317 !macroend
318 !define UnattendedMode `"" UnattendedMode ""`
320 !macro _ForcedMode _a _b _t _f
321 !insertmacro _LOGICLIB_TEMP
322 ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Force"
323 StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
324 !macroend
325 !define ForcedMode `"" ForcedMode ""`
327 !macro _ValidFileName _a _b _t _f
328 !insertmacro _LOGICLIB_TEMP
329 ${StdUtils.ValidFileName} $_LOGICLIB_TEMP `${_b}`
330 StrCmp "$_LOGICLIB_TEMP" "ok" `${_t}` `${_f}`
331 !macroend
332 !define ValidFileName `"" ValidFileName`
335 ;--------------------------------
336 ;Installer initialization
337 ;--------------------------------
339 Function .onInit
340 InitPluginsDir
342 ; --------
344 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
345 Pop $0
346 ${If} $0 <> 0
347 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the installer is already running!"
348 Quit
349 ${EndIf}
351 ; --------
353 # Running on Windows NT family?
354 ${IfNot} ${IsNT}
355 MessageBox MB_TOPMOST|MB_ICONSTOP "Sorry, this application does *not* support Windows 9x/ME!"
356 ExecShell "open" "http://windows.microsoft.com/"
357 Quit
358 ${EndIf}
360 # Running on Windows XP or later?
361 ${If} ${AtMostWin2000}
362 MessageBox MB_TOPMOST|MB_ICONSTOP "Sorry, but your operating system is *not* supported anymore.$\nInstallation will be aborted!$\n$\nThe minimum required platform is Windows XP (Service Pack 3)."
363 ExecShell "open" "http://windows.microsoft.com/"
364 Quit
365 ${EndIf}
367 # If on Windows XP, is the required Service Pack installed?
368 ${If} ${IsWinXP}
369 ${IfNot} ${RunningX64} # Windows XP 32-Bit, requires Service Pack 3
370 ${AndIf} ${AtMostServicePack} 2
371 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Service Pack 3 for Windows XP.$\nPlease install the required Service Pack and retry!"
372 Quit
373 ${EndIf}
374 ${If} ${RunningX64} # Windows XP 64-Bit, requires Service Pack 2
375 ${AndIf} ${AtMostServicePack} 1
376 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Service Pack 2 for Windows XP x64.$\nPlease install the required Service Pack and retry!"
377 Quit
378 ${EndIf}
379 ${IfNot} ${UnattendedMode}
380 ${If} ${Cmd} `MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OKCANCEL|MB_DEFBUTTON2 "It appears that you are still running Windows XP, which reached $\"end of life$\" in April 2014 and therefore will not receive any updates or bug fixes anymore - not even for critical security vulnerabilities! We highly recommend updating to a contemporary operating system.$\n$\nClick 'OK' to proceed with the installation, or click 'Cancel' to abort." IDCANCEL`
381 Quit
382 ${EndIf}
383 ${EndIf}
384 ${EndIf}
386 # Running on Windows Vista?
387 ${If} ${IsWinVista}
388 ${If} ${AtMostServicePack} 1
389 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Service Pack 2 for Windows Vista.$\nPlease install the required Service Pack and retry!"
390 Quit
391 ${EndIf}
392 ${IfNot} ${UnattendedMode}
393 ${If} ${Cmd} `MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OKCANCEL|MB_DEFBUTTON2 "It appears that you are still running Windows Vista, which reached $\"end of life$\" in April 2017 and therefore will not receive any updates or bug fixes anymore - not even for critical security vulnerabilities! We highly recommend updating to a contemporary operating system.$\n$\nClick 'OK' to proceed with the installation, or click 'Cancel' to abort." IDCANCEL`
394 Quit
395 ${EndIf}
396 ${EndIf}
397 ${EndIf}
399 ; --------
401 ${IfNot} ${UnattendedMode}
402 !insertmacro MUI_LANGDLL_DISPLAY
403 ${EndIf}
405 ; --------
407 UserInfo::GetAccountType
408 Pop $0
409 ${If} $0 != "Admin"
410 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
411 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
412 Quit
413 ${EndIf}
414 FunctionEnd
416 Function un.onInit
417 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
418 Pop $0
419 ${If} $0 <> 0
420 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the un-installer is already running!"
421 Quit
422 ${EndIf}
424 ${IfNot} ${ForcedMode}
425 !insertmacro MUI_LANGDLL_DISPLAY
426 ${EndIf}
428 ; --------
430 UserInfo::GetAccountType
431 Pop $0
432 ${If} $0 != "Admin"
433 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
434 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
435 Quit
436 ${EndIf}
437 FunctionEnd
440 ;--------------------------------
441 ;GUI initialization
442 ;--------------------------------
444 Function MyGuiInit
445 StrCpy $0 $HWNDPARENT
446 System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
447 Aero::Apply
448 FunctionEnd
450 Function un.MyGuiInit
451 StrCpy $0 $HWNDPARENT
452 System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
453 Aero::Apply
454 FunctionEnd
457 ;--------------------------------
458 ;Macros & Auxiliary Functions
459 ;--------------------------------
461 !macro PrintProgress Text
462 SetDetailsPrint textonly
463 DetailPrint '${Text}'
464 SetDetailsPrint listonly
465 Sleep 1000
466 !macroend
468 !macro CreateWebLink ShortcutFile TargetURL
469 Push $0
470 Push $1
471 StrCpy $0 "${ShortcutFile}"
472 StrCpy $1 "${TargetURL}"
473 Call _CreateWebLink
474 Pop $1
475 Pop $0
476 !macroend
478 Function _CreateWebLink
479 FlushINI "$0"
480 SetFileAttributes "$0" FILE_ATTRIBUTE_NORMAL
481 DeleteINISec "$0" "DEFAULT"
482 DeleteINISec "$0" "InternetShortcut"
483 WriteINIStr "$0" "DEFAULT" "BASEURL" "$1"
484 WriteINIStr "$0" "InternetShortcut" "ORIGURL" "$1"
485 WriteINIStr "$0" "InternetShortcut" "URL" "$1"
486 WriteINIStr "$0" "InternetShortcut" "IconFile" "$SYSDIR\SHELL32.dll"
487 WriteINIStr "$0" "InternetShortcut" "IconIndex" "150"
488 FlushINI "$0"
489 SetFileAttributes "$0" FILE_ATTRIBUTE_READONLY
490 FunctionEnd
492 !macro GetExecutableName OutVar
493 ${StdUtils.GetParameter} ${OutVar} "Update" ""
494 ${StdUtils.TrimStr} ${OutVar}
495 ${If} "${OutVar}" == ""
496 ${OrIfNot} ${ValidFileName} "${OutVar}"
497 StrCpy ${OutVar} "LameXP.exe"
498 ${EndIf}
499 !macroend
501 !macro DisableNextButton TmpVar
502 GetDlgItem ${TmpVar} $HWNDPARENT 1
503 EnableWindow ${TmpVar} 0
504 !macroend
506 !macro DisableBackButton TmpVar
507 GetDlgItem ${TmpVar} $HWNDPARENT 3
508 EnableWindow ${TmpVar} 0
509 !macroend
511 !macro CleanUpFiles options
512 Delete ${options} "$INSTDIR\Changelog.htm"
513 Delete ${options} "$INSTDIR\Changelog.html"
514 Delete ${options} "$INSTDIR\Contributors.txt"
515 Delete ${options} "$INSTDIR\Copying.txt"
516 Delete ${options} "$INSTDIR\FAQ.html"
517 Delete ${options} "$INSTDIR\Howto.html"
518 Delete ${options} "$INSTDIR\LameEnc.sys"
519 Delete ${options} "$INSTDIR\LameXP*.exe"
520 Delete ${options} "$INSTDIR\LameXP*.exe.sig"
521 Delete ${options} "$INSTDIR\LameXP*.rcc"
522 Delete ${options} "$INSTDIR\LameXP*.VisualElementsManifest.xml"
523 Delete ${options} "$INSTDIR\License.txt"
524 Delete ${options} "$INSTDIR\Manual.html"
525 Delete ${options} "$INSTDIR\Readme.htm"
526 Delete ${options} "$INSTDIR\ReadMe.txt"
527 Delete ${options} "$INSTDIR\PRE_RELEASE_INFO.txt"
528 Delete ${options} "$INSTDIR\Settings.cfg"
529 Delete ${options} "$INSTDIR\Translate.html"
530 Delete ${options} "$INSTDIR\Uninstall.exe"
531 Delete ${options} "$INSTDIR\Qt*.dll"
532 Delete ${options} "$INSTDIR\MUtils*.dll"
533 Delete ${options} "$INSTDIR\msvcr*.dll"
534 Delete ${options} "$INSTDIR\msvcp*.dll"
535 Delete ${options} "$INSTDIR\concrt*.dll"
536 Delete ${options} "$INSTDIR\vcruntime*.dll"
537 Delete ${options} "$INSTDIR\vccorlib*.dll"
538 Delete ${options} "$INSTDIR\api-ms-*.dll"
539 Delete ${options} "$INSTDIR\ucrtbase.dll"
541 RMDir /r ${options} "$INSTDIR\cache"
542 RMDir /r ${options} "$INSTDIR\img"
543 RMDir /r ${options} "$INSTDIR\imageformats"
544 RMDir /r ${options} "$INSTDIR\redist"
545 !macroend
547 ;--------------------------------
548 ;Install Files
549 ;--------------------------------
551 Section "-PreInit"
552 SetShellVarContext all
553 SetOutPath "$INSTDIR"
554 SectionEnd
556 Section "-Clean Up Old Cruft"
557 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_CLEANUP)"
558 !insertmacro CleanUpFiles ""
559 SectionEnd
561 Section "!Install Files"
562 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_INSTFILES)"
564 DeleteOldBinary:
565 !insertmacro GetExecutableName $R0
566 ClearErrors
567 Delete "$INSTDIR\$R0"
569 ${If} ${Errors}
570 MessageBox MB_TOPMOST|MB_ICONSTOP|MB_RETRYCANCEL 'Could not delete old "$R0" file. Is LameXP still running?' IDRETRY DeleteOldBinary
571 Abort "Could not delete old binary!"
572 ${EndIf}
574 File /a `/oname=$R0` `${LAMEXP_SOURCE_PATH}\LameXP.exe`
575 File /nonfatal /a /r `${LAMEXP_SOURCE_PATH}\*.dll`
577 ${StdUtils.GetFileNamePart} $R1 "$R0"
578 File /a `/oname=$R1.VisualElementsManifest.xml` `${LAMEXP_SOURCE_PATH}\LameXP.VisualElementsManifest.xml`
579 File /a `/oname=$R1.tag` `${LAMEXP_SOURCE_PATH}\LameXP.tag`
581 File /a /r `${LAMEXP_SOURCE_PATH}\*.txt`
582 File /a /r `${LAMEXP_SOURCE_PATH}\*.html`
583 File /a /r `${LAMEXP_SOURCE_PATH}\*.png`
584 SectionEnd
586 # Section "-Install VCRedist"
587 # !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_VCREDIST)"
588 # File /a `/oname=$PLUGINSDIR\vcredist_x86.exe` `${LAMEXP_SOURCE_PATH}\redist\vcredist_x86.exe`
589 # ExecWait '"$PLUGINSDIR\vcredist_x86.exe" /install /passive /norestart'
590 # SectionEnd
592 Section "-Write Uninstaller"
593 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_MAKEUNINST)"
594 WriteUninstaller "$INSTDIR\Uninstall.exe"
595 SectionEnd
597 Section "-Create Shortcuts"
598 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
599 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_SHORTCUTS)"
600 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
602 SetShellVarContext current
604 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
605 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
606 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
608 SetShellVarContext all
610 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
611 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
612 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
614 !insertmacro GetExecutableName $R0
616 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" "$INSTDIR\$R0" "" "$INSTDIR\$R0" 0
617 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_LICENSE).lnk" "$INSTDIR\License.txt"
618 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_CHANGELOG).lnk" "$INSTDIR\Changelog.html"
619 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_TRANSLATE).lnk" "$INSTDIR\Translate.html"
620 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_MANUAL).lnk" "$INSTDIR\Manual.html"
621 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_UNINSTALL).lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
623 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Official LameXP Homepage.url" "${MyWebSite}"
624 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Doom9's Forum.url" "http://forum.doom9.org/"
625 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Bug Tracker.url" "https://github.com/lordmulder/LameXP/issues"
626 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\RareWares.org.url" "http://rarewares.org/"
627 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Hydrogenaudio Forums.url" "http://www.hydrogenaudio.org/"
629 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"
630 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "LameXP.lnk" ${StdUtils.Const.ShellVerb.PinToTaskbar}
631 DetailPrint 'Pin: "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" -> $R1'
632 ${EndIf}
633 !insertmacro MUI_STARTMENU_WRITE_END
634 SectionEnd
636 Section "-Update Registry"
637 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_REGISTRY)"
639 !insertmacro GetExecutableName $R0
640 WriteRegStr HKLM "${MyRegPath}" "InstallLocation" "$INSTDIR"
641 WriteRegStr HKLM "${MyRegPath}" "ExecutableName" "$R0"
642 WriteRegStr HKLM "${MyRegPath}" "DisplayIcon" "$INSTDIR\$R0,0"
643 WriteRegStr HKLM "${MyRegPath}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
644 WriteRegStr HKLM "${MyRegPath}" "DisplayName" "LameXP v${LAMEXP_VERSION}"
645 WriteRegStr HKLM "${MyRegPath}" "Publisher" "LoRd_MuldeR <mulder2@gmx.de>"
646 WriteRegStr HKLM "${MyRegPath}" "DisplayVersion" "${LAMEXP_VERSION} ${LAMEXP_INSTTYPE}-${LAMEXP_PATCH} [Build #${LAMEXP_BUILD}]"
647 WriteRegStr HKLM "${MyRegPath}" "URLInfoAbout" "${MyWebSite}"
648 WriteRegStr HKLM "${MyRegPath}" "URLUpdateInfo" "${MyWebSite}"
650 DeleteRegKey HKCU "${AppPaths}\LameXP.exe"
651 WriteRegStr HKLM "${AppPaths}\LameXP.exe" "" "$INSTDIR\$R0"
652 WriteRegStr HKLM "${AppPaths}\LameXP.exe" "Path" "$INSTDIR"
653 SectionEnd
655 Section "-Finished"
656 !insertmacro PrintProgress "$(MUI_TEXT_FINISH_TITLE)."
658 !ifdef LAMEXP_IS_PRERELEASE
659 ${If} ${FileExists} "$INSTDIR\PRE_RELEASE_INFO.txt"
660 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\PRE_RELEASE_INFO.txt" "open" ""
661 ${EndIf}
662 !endif
664 ${IfThen} ${UnattendedMode} ${|} SetAutoClose true ${|}
665 SectionEnd
668 ;--------------------------------
669 ;Uninstaller
670 ;--------------------------------
672 Section "Uninstall"
673 SetOutPath "$EXEDIR"
674 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_UNINSTALL)"
676 ; --------------
677 ; Startmenu
678 ; --------------
680 !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
681 ${IfNot} "$StartMenuFolder" == ""
682 SetShellVarContext current
683 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"
684 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "LameXP.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
685 DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" -> $R1'
686 ${EndIf}
687 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
688 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
689 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
690 RMDir "$SMPROGRAMS\$StartMenuFolder"
691 ${EndIf}
693 SetShellVarContext all
694 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"
695 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "LameXP.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
696 DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" -> $R1'
697 ${EndIf}
698 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
699 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
700 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
701 RMDir "$SMPROGRAMS\$StartMenuFolder"
702 ${EndIf}
703 ${EndIf}
705 ; --------------
706 ; Files
707 ; --------------
709 ReadRegStr $R0 HKLM "${MyRegPath}" "ExecutableName"
710 ${IfThen} "$R0" == "" ${|} StrCpy $R0 "LameXP.exe" ${|}
711 ExecWait '"$INSTDIR\$R0" --uninstall'
713 Delete /REBOOTOK "$INSTDIR\$R0"
714 !insertmacro CleanUpFiles /REBOOTOK
715 RMDir "$INSTDIR"
717 ; --------------
718 ; Registry
719 ; --------------
721 DeleteRegKey HKLM "${MyRegPath}"
722 DeleteRegKey HKCU "${MyRegPath}"
724 DeleteRegKey HKLM "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
725 DeleteRegKey HKCU "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
727 DeleteRegKey HKLM "${AppPaths}\LameXP.exe"
728 DeleteRegKey HKCU "${AppPaths}\LameXP.exe"
730 MessageBox MB_YESNO|MB_TOPMOST "$(LAMEXP_LANG_UNINST_PERSONAL)" IDNO +3
731 Delete "$LOCALAPPDATA\LoRd_MuldeR\LameXP - Audio Encoder Front-End\config.ini"
732 Delete "$INSTDIR\*.ini"
734 !insertmacro PrintProgress "$(MUI_UNTEXT_FINISH_TITLE)."
735 SectionEnd
738 ;--------------------------------
739 ;Check For Update Mode
740 ;--------------------------------
742 Function SkipIfUnattended
743 ${IfThen} ${UnattendedMode} ${|} Abort ${|}
744 FunctionEnd
746 Function CheckForUpdate
747 ${If} "$INSTDIR" == ""
748 ${OrIf} "$INSTDIR" == "$EXEDIR"
749 ${OrIfNot} ${FileExists} "$INSTDIR\LameXP.exe"
750 Return
751 ${EndIf}
753 FindWindow $R0 "#32770" "" $HWNDPARENT
754 GetDlgItem $R1 $R0 1019
755 EnableWindow $R1 0
757 FindWindow $R0 "#32770" "" $HWNDPARENT
758 GetDlgItem $R1 $R0 1001
759 EnableWindow $R1 0
760 FunctionEnd
762 Function un.CheckForcedUninstall
763 ${IfThen} ${ForcedMode} ${|} Abort ${|}
764 FunctionEnd
767 ;--------------------------------
768 ;Check For Pre-Release
769 ;--------------------------------
771 Function CheckForPreRelease
772 !ifdef LAMEXP_IS_PRERELEASE
773 ${IfNot} ${UnattendedMode}
774 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OKCANCEL "$(LAMEXP_LANG_PRERELEASE_WARNING)" /SD IDOK IDOK +2
775 Quit
776 ${EndIf}
777 !endif
778 FunctionEnd
781 ;--------------------------------
782 ;Locked List
783 ;--------------------------------
785 !macro _LockedListShow uinst
786 !insertmacro MUI_HEADER_TEXT "$(LAMEXP_LANG_LOCKEDLIST_HEADER)" "$(LAMEXP_LANG_LOCKEDLIST_TEXT)"
787 ${If} ${UnattendedMode}
788 !insertmacro DisableBackButton $R0
789 ${EndIf}
790 ${If} ${RunningX64}
791 InitPluginsDir
792 File /oname=$PLUGINSDIR\LockedList64.dll `${NSISDIR}\Plugins\LockedList64.dll`
793 ${EndIf}
794 !insertmacro GetExecutableName $R0
795 LockedList::AddModule "\$R0"
796 ${If} "$R0" != "LameXP.exe"
797 LockedList::AddModule "\LameXP.exe"
798 ${EndIf}
799 LockedList::AddModule "\Uninstall.exe"
800 !if ${uinst} < 1
801 LockedList::AddModule "\Au_.exe"
802 !endif
803 #LockedList::AddFolder "$INSTDIR"
804 LockedList::Dialog /autonext /heading "$(LAMEXP_LANG_LOCKEDLIST_HEADING)" /noprograms "$(LAMEXP_LANG_LOCKEDLIST_NOPROG)" /searching "$(LAMEXP_LANG_LOCKEDLIST_SEARCH)" /colheadings "$(LAMEXP_LANG_LOCKEDLIST_COLHDR1)" "$(LAMEXP_LANG_LOCKEDLIST_COLHDR2)"
805 Pop $R0
806 !macroend
808 Function LockedListShow
809 !insertmacro _LockedListShow 0
810 FunctionEnd
812 Function un.LockedListShow
813 !insertmacro _LockedListShow 1
814 FunctionEnd
817 ;--------------------------------
818 ;Install Success
819 ;--------------------------------
821 Function RunAppFunction
822 !insertmacro DisableNextButton $R0
823 !insertmacro GetExecutableName $R0
824 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR" "explore" ""
825 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\$R0" "open" "--first-run"
826 FunctionEnd
828 Function ShowReadmeFunction
829 !insertmacro DisableNextButton $R0
830 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\Manual.html" "open" ""
831 FunctionEnd
833 Function .onInstSuccess
834 ${If} ${UnattendedMode}
835 !insertmacro GetExecutableName $R0
836 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\$R0" "open" "--first-run"
837 ${EndIf}
838 FunctionEnd