Small installer fix.
[LameXP.git] / etc / NSIS / setup.nsi
blob1d668cb881bc6969705846181de5822ef9c57506
1 ; ///////////////////////////////////////////////////////////////////////////////
2 ; // LameXP - Audio Encoder Front-End
3 ; // Copyright (C) 2004-2016 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
52 !ifndef LAMEXP_UPX_PATH
53 !error "LAMEXP_UPX_PATH is not defined !!!"
54 !endif
56 ;UUID
57 !define MyRegPath "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{FBD7A67D-D700-4043-B54F-DD106D00F308}"
59 ;App Paths
60 !define AppPaths "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"
62 ;Web-Site
63 !define MyWebSite "http://muldersoft.com/"
66 ;--------------------------------
67 ;Check for Pre-Release
68 ;--------------------------------
70 !define LAMEXP_IS_PRERELEASE
72 !if '${LAMEXP_INSTTYPE}' == 'Final'
73 !undef LAMEXP_IS_PRERELEASE
74 !endif
75 !if '${LAMEXP_INSTTYPE}' == 'Hotfix'
76 !undef LAMEXP_IS_PRERELEASE
77 !endif
80 ;--------------------------------
81 ;Manifest
82 ;--------------------------------
84 !tempfile PACKHDRTEMP
85 !packhdr "${PACKHDRTEMP}" '"..\..\..\Prerequisites\MSVC\redist\bin\mt.exe" -manifest "setup.manifest" -outputresource:"${PACKHDRTEMP};1" && "..\..\..\Prerequisites\UPX\upx.exe" --brute "${PACKHDRTEMP}"'
88 ;--------------------------------
89 ;Includes
90 ;--------------------------------
92 !include `MUI2.nsh`
93 !include `WinVer.nsh`
94 !include `x64.nsh`
95 !include `StdUtils.nsh`
98 ;--------------------------------
99 ;Installer Attributes
100 ;--------------------------------
102 RequestExecutionLevel admin
103 ShowInstDetails show
104 ShowUninstDetails show
105 Name "LameXP v${LAMEXP_VERSION} ${LAMEXP_INSTTYPE}-${LAMEXP_PATCH} [Build #${LAMEXP_BUILD}]"
106 OutFile "${LAMEXP_OUTPUT_FILE}"
107 BrandingText "Date created: ${LAMEXP_DATE} [Build #${LAMEXP_BUILD}]"
108 InstallDir "$PROGRAMFILES\MuldeR\LameXP v${LAMEXP_VERSION}"
109 InstallDirRegKey HKLM "${MyRegPath}" "InstallLocation"
112 ;--------------------------------
113 ;Compressor
114 ;--------------------------------
116 SetCompressor /SOLID LZMA
117 SetCompressorDictSize 64
120 ;--------------------------------
121 ;Reserved Files
122 ;--------------------------------
124 ReserveFile "${NSISDIR}\Plugins\Aero.dll"
125 ReserveFile "${NSISDIR}\Plugins\LangDLL.dll"
126 ReserveFile "${NSISDIR}\Plugins\LockedList.dll"
127 ReserveFile "${NSISDIR}\Plugins\LockedList64.dll"
128 ReserveFile "${NSISDIR}\Plugins\nsDialogs.dll"
129 ReserveFile "${NSISDIR}\Plugins\nsExec.dll"
130 ReserveFile "${NSISDIR}\Plugins\StartMenu.dll"
131 ReserveFile "${NSISDIR}\Plugins\StdUtils.dll"
132 ReserveFile "${NSISDIR}\Plugins\System.dll"
133 ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
136 ;--------------------------------
137 ;Variables
138 ;--------------------------------
140 Var StartMenuFolder
143 ;--------------------------------
144 ;Version Info
145 ;--------------------------------
147 !searchreplace PRODUCT_VERSION_DATE "${LAMEXP_DATE}" "-" "."
148 VIProductVersion "${PRODUCT_VERSION_DATE}.${LAMEXP_BUILD}"
150 VIAddVersionKey "Author" "LoRd_MuldeR <mulder2@gmx.de>"
151 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."
152 VIAddVersionKey "CompanyName" "Free Software Foundation"
153 VIAddVersionKey "FileDescription" "LameXP v${LAMEXP_VERSION} ${LAMEXP_INSTTYPE}-${LAMEXP_PATCH} [Build #${LAMEXP_BUILD}]"
154 VIAddVersionKey "FileVersion" "${PRODUCT_VERSION_DATE}.${LAMEXP_BUILD} (${LAMEXP_VERSION})"
155 VIAddVersionKey "LegalCopyright" "Copyright 2004-2016 LoRd_MuldeR"
156 VIAddVersionKey "LegalTrademarks" "GNU"
157 VIAddVersionKey "OriginalFilename" "LameXP.${LAMEXP_DATE}.exe"
158 VIAddVersionKey "ProductName" "LameXP - Audio Encoder Frontend"
159 VIAddVersionKey "ProductVersion" "${LAMEXP_VERSION}, Build #${LAMEXP_BUILD} (${LAMEXP_DATE})"
160 VIAddVersionKey "Website" "${MyWebSite}"
163 ;--------------------------------
164 ;MUI2 Interface Settings
165 ;--------------------------------
167 !define MUI_ABORTWARNING
168 !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
169 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${MyRegPath}"
170 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartmenuFolder"
171 !define MUI_LANGDLL_REGISTRY_ROOT HKLM
172 !define MUI_LANGDLL_REGISTRY_KEY "${MyRegPath}"
173 !define MUI_LANGDLL_REGISTRY_VALUENAME "SetupLanguage"
174 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "LameXP v${LAMEXP_VERSION}"
175 !define MUI_FINISHPAGE_NOAUTOCLOSE
176 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
177 !define MUI_FINISHPAGE_RUN
178 !define MUI_FINISHPAGE_RUN_FUNCTION RunAppFunction
179 !define MUI_FINISHPAGE_SHOWREADME
180 !define MUI_FINISHPAGE_SHOWREADME_FUNCTION ShowReadmeFunction
181 !define MUI_FINISHPAGE_LINK ${MyWebSite}
182 !define MUI_FINISHPAGE_LINK_LOCATION ${MyWebSite}
183 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
184 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"
185 !define MUI_WELCOMEFINISHPAGE_BITMAP "wizard.bmp"
186 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "wizard-un.bmp"
187 !define MUI_HEADERIMAGE
188 !define MUI_HEADERIMAGE_BITMAP "header.bmp"
189 !define MUI_HEADERIMAGE_UNBITMAP "header-un.bmp"
190 !define MUI_LANGDLL_ALLLANGUAGES
191 !define MUI_CUSTOMFUNCTION_GUIINIT MyGuiInit
192 !define MUI_CUSTOMFUNCTION_UNGUIINIT un.MyGuiInit
193 !define MUI_LANGDLL_ALWAYSSHOW
196 ;--------------------------------
197 ;MUI2 Pages (Installer)
198 ;--------------------------------
200 ;Welcome
201 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
202 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE CheckForPreRelease
203 !define MUI_WELCOMEPAGE_TITLE_3LINES
204 !define MUI_FINISHPAGE_TITLE_3LINES
205 !insertmacro MUI_PAGE_WELCOME
207 ;License
208 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
209 !insertmacro MUI_PAGE_LICENSE "license.rtf"
211 ;Directory
212 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
213 !define MUI_PAGE_CUSTOMFUNCTION_SHOW CheckForUpdate
214 !insertmacro MUI_PAGE_DIRECTORY
216 ;Startmenu
217 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
218 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
220 ;LockedList
221 Page Custom LockedListShow
223 ;Install Files
224 !insertmacro MUI_PAGE_INSTFILES
226 ;Finish
227 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
228 !insertmacro MUI_PAGE_FINISH
231 ;--------------------------------
232 ;MUI2 Pages (Uninstaller)
233 ;--------------------------------
235 ;Welcome
236 !define MUI_WELCOMEPAGE_TITLE_3LINES
237 !define MUI_FINISHPAGE_TITLE_3LINES
238 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
239 !insertmacro MUI_UNPAGE_WELCOME
241 ;Confirm
242 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
243 !insertmacro MUI_UNPAGE_CONFIRM
245 ;LockedList
246 UninstPage Custom un.LockedListShow
248 ;Uninstall
249 !insertmacro MUI_UNPAGE_INSTFILES
251 ;Finish
252 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
253 !insertmacro MUI_UNPAGE_FINISH
256 ;--------------------------------
257 ;Languages
258 ;--------------------------------
260 !insertmacro MUI_LANGUAGE "English" ;first language is the default language
261 !insertmacro MUI_LANGUAGE "German"
262 !insertmacro MUI_LANGUAGE "Spanish"
263 !insertmacro MUI_LANGUAGE "Russian"
264 !insertmacro MUI_LANGUAGE "Ukrainian"
265 !insertmacro MUI_LANGUAGE "Polish"
266 !insertmacro MUI_LANGUAGE "Hungarian"
268 ; !insertmacro MUI_LANGUAGE "French"
269 ; !insertmacro MUI_LANGUAGE "SpanishInternational"
270 ; !insertmacro MUI_LANGUAGE "SimpChinese"
271 ; !insertmacro MUI_LANGUAGE "TradChinese"
272 ; !insertmacro MUI_LANGUAGE "Japanese"
273 ; !insertmacro MUI_LANGUAGE "Italian"
274 ; !insertmacro MUI_LANGUAGE "Dutch"
275 ; !insertmacro MUI_LANGUAGE "Greek"
276 ; !insertmacro MUI_LANGUAGE "Romanian"
277 ; !insertmacro MUI_LANGUAGE "Serbian"
278 ; !insertmacro MUI_LANGUAGE "SerbianLatin"
279 ; !insertmacro MUI_LANGUAGE "Arabic"
280 ; !insertmacro MUI_LANGUAGE "Portuguese"
281 ; !insertmacro MUI_LANGUAGE "Afrikaans"
282 ; !insertmacro MUI_LANGUAGE "Malay"
283 ; !insertmacro MUI_LANGUAGE "Indonesian"
286 ;--------------------------------
287 ;Translation
288 ;--------------------------------
290 ;English
291 !include "..\Translation\Blank.nsh"
293 ;German
294 !include "..\Translation\LameXP_DE.nsh"
296 ;Spanish
297 !include "..\Translation\LameXP_ES.nsh"
299 ;Russian
300 !include "..\Translation\LameXP_RU.nsh"
302 ;Ukrainian
303 !include "..\Translation\LameXP_UK.nsh"
305 ;Polish
306 !include "..\Translation\LameXP_PL.nsh"
308 ;Hungarian
309 !include "..\Translation\LameXP_HU.nsh"
312 ;--------------------------------
313 ;LogicLib Extensions
314 ;--------------------------------
316 !macro _UnattendedMode _a _b _t _f
317 !insertmacro _LOGICLIB_TEMP
318 ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Update"
319 StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
320 !macroend
321 !define UnattendedMode `"" UnattendedMode ""`
323 !macro _ForcedMode _a _b _t _f
324 !insertmacro _LOGICLIB_TEMP
325 ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Force"
326 StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
327 !macroend
328 !define ForcedMode `"" ForcedMode ""`
330 !macro _ValidFileName _a _b _t _f
331 !insertmacro _LOGICLIB_TEMP
332 ${StdUtils.ValidFileName} $_LOGICLIB_TEMP `${_b}`
333 StrCmp "$_LOGICLIB_TEMP" "ok" `${_t}` `${_f}`
334 !macroend
335 !define ValidFileName `"" ValidFileName`
338 ;--------------------------------
339 ;Installer initialization
340 ;--------------------------------
342 Function .onInit
343 InitPluginsDir
345 ; --------
347 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
348 Pop $0
349 ${If} $0 <> 0
350 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the installer is already running!"
351 Quit
352 ${EndIf}
354 ; --------
356 # Running on Windows NT family?
357 ${IfNot} ${IsNT}
358 MessageBox MB_TOPMOST|MB_ICONSTOP "Sorry, this application does *not* support Windows 9x or Windows ME!"
359 ExecShell "open" "http://windows.microsoft.com/"
360 Quit
361 ${EndIf}
363 # Running on Windows XP or later?
364 ${If} ${AtMostWin2000}
365 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)."
366 ExecShell "open" "http://windows.microsoft.com/"
367 Quit
368 ${EndIf}
370 # If on Windows XP, is the required Service Pack installed?
371 ${If} ${IsWinXP}
372 ${IfNot} ${RunningX64} # Windows XP 32-Bit, requires Service Pack 3
373 ${AndIf} ${AtMostServicePack} 2
374 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Windows XP with Service Pack 3 installed!"
375 ${If} ${Cmd} `MessageBox MB_TOPMOST|MB_ICONQUESTION|MB_YESNO "Do you want to download Service Pack 3 for Windows XP now?" IDYES`
376 ExecShell "open" "http://www.microsoft.com/en-us/download/details.aspx?id=24"
377 ${Else}
378 ExecShell "open" "http://windowsupdate.microsoft.com/"
379 ${EndIf}
380 Quit
381 ${EndIf}
382 ${If} ${RunningX64} # Windows XP 64-Bit, requires Service Pack 2
383 ${AndIf} ${AtMostServicePack} 1
384 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Windows XP x64 Edition with Service Pack 2 installed!"
385 ${If} ${Cmd} `MessageBox MB_TOPMOST|MB_ICONQUESTION|MB_YESNO "Do you want to download Service Pack 2 for Windows XP x64 Edition now?" IDYES`
386 ExecShell "open" "http://www.microsoft.com/en-us/download/details.aspx?id=17791"
387 ${Else}
388 ExecShell "open" "http://windowsupdate.microsoft.com/"
389 ${EndIf}
390 Quit
391 ${EndIf}
392 ${EndIf}
394 ; --------
396 ${IfNot} ${UnattendedMode}
397 !insertmacro MUI_LANGDLL_DISPLAY
398 ${EndIf}
400 ; --------
402 UserInfo::GetAccountType
403 Pop $0
404 ${If} $0 != "Admin"
405 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
406 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
407 Quit
408 ${EndIf}
409 FunctionEnd
411 Function un.onInit
412 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
413 Pop $0
414 ${If} $0 <> 0
415 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the un-installer is already running!"
416 Quit
417 ${EndIf}
419 ${IfNot} ${ForcedMode}
420 !insertmacro MUI_LANGDLL_DISPLAY
421 ${EndIf}
423 ; --------
425 UserInfo::GetAccountType
426 Pop $0
427 ${If} $0 != "Admin"
428 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
429 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
430 Quit
431 ${EndIf}
432 FunctionEnd
435 ;--------------------------------
436 ;GUI initialization
437 ;--------------------------------
439 Function MyGuiInit
440 StrCpy $0 $HWNDPARENT
441 System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
442 Aero::Apply
443 FunctionEnd
445 Function un.MyGuiInit
446 StrCpy $0 $HWNDPARENT
447 System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
448 Aero::Apply
449 FunctionEnd
452 ;--------------------------------
453 ;Macros & Auxiliary Functions
454 ;--------------------------------
456 !macro PrintProgress Text
457 SetDetailsPrint textonly
458 DetailPrint '${Text}'
459 SetDetailsPrint listonly
460 Sleep 1000
461 !macroend
463 !macro CreateWebLink ShortcutFile TargetURL
464 Push $0
465 Push $1
466 StrCpy $0 "${ShortcutFile}"
467 StrCpy $1 "${TargetURL}"
468 Call _CreateWebLink
469 Pop $1
470 Pop $0
471 !macroend
473 Function _CreateWebLink
474 FlushINI "$0"
475 SetFileAttributes "$0" FILE_ATTRIBUTE_NORMAL
476 DeleteINISec "$0" "DEFAULT"
477 DeleteINISec "$0" "InternetShortcut"
478 WriteINIStr "$0" "DEFAULT" "BASEURL" "$1"
479 WriteINIStr "$0" "InternetShortcut" "ORIGURL" "$1"
480 WriteINIStr "$0" "InternetShortcut" "URL" "$1"
481 WriteINIStr "$0" "InternetShortcut" "IconFile" "$SYSDIR\SHELL32.dll"
482 WriteINIStr "$0" "InternetShortcut" "IconIndex" "150"
483 FlushINI "$0"
484 SetFileAttributes "$0" FILE_ATTRIBUTE_READONLY
485 FunctionEnd
487 !macro GetExecutableName OutVar
488 ${StdUtils.GetParameter} ${OutVar} "Update" ""
489 ${StdUtils.TrimStr} ${OutVar}
490 ${If} "${OutVar}" == ""
491 ${OrIfNot} ${ValidFileName} "${OutVar}"
492 StrCpy ${OutVar} "LameXP.exe"
493 ${EndIf}
494 !macroend
496 !macro DisableNextButton TmpVar
497 GetDlgItem ${TmpVar} $HWNDPARENT 1
498 EnableWindow ${TmpVar} 0
499 !macroend
501 !macro DisableBackButton TmpVar
502 GetDlgItem ${TmpVar} $HWNDPARENT 3
503 EnableWindow ${TmpVar} 0
504 !macroend
506 !macro CleanUpFiles options
507 Delete ${options} "$INSTDIR\Changelog.htm"
508 Delete ${options} "$INSTDIR\Changelog.html"
509 Delete ${options} "$INSTDIR\Contributors.txt"
510 Delete ${options} "$INSTDIR\Copying.txt"
511 Delete ${options} "$INSTDIR\FAQ.html"
512 Delete ${options} "$INSTDIR\Howto.html"
513 Delete ${options} "$INSTDIR\LameEnc.sys"
514 Delete ${options} "$INSTDIR\LameXP.exe"
515 Delete ${options} "$INSTDIR\LameXP.exe.sig"
516 Delete ${options} "$INSTDIR\LameXP-Portable.exe"
517 Delete ${options} "$INSTDIR\License.txt"
518 Delete ${options} "$INSTDIR\Manual.html"
519 Delete ${options} "$INSTDIR\Readme.htm"
520 Delete ${options} "$INSTDIR\ReadMe.txt"
521 Delete ${options} "$INSTDIR\PRE_RELEASE_INFO.txt"
522 Delete ${options} "$INSTDIR\Settings.cfg"
523 Delete ${options} "$INSTDIR\Translate.html"
524 Delete ${options} "$INSTDIR\Uninstall.exe"
525 Delete ${options} "$INSTDIR\Qt*.dll"
526 Delete ${options} "$INSTDIR\MUtils*.dll"
527 Delete ${options} "$INSTDIR\msvcr*.dll"
528 Delete ${options} "$INSTDIR\msvcp*.dll"
529 Delete ${options} "$INSTDIR\concrt*.dll"
530 Delete ${options} "$INSTDIR\vcruntime*.dll"
531 Delete ${options} "$INSTDIR\vccorlib*.dll"
532 Delete ${options} "$INSTDIR\api-ms-*.dll"
533 Delete ${options} "$INSTDIR\ucrtbase.dll"
535 RMDir /r ${options} "$INSTDIR\cache"
536 RMDir /r ${options} "$INSTDIR\img"
537 RMDir /r ${options} "$INSTDIR\imageformats"
538 RMDir /r ${options} "$INSTDIR\redist"
539 !macroend
541 ;--------------------------------
542 ;Install Files
543 ;--------------------------------
545 Section "-PreInit"
546 SetShellVarContext all
547 SetOutPath "$INSTDIR"
548 SectionEnd
550 Section "-Clean Up Old Cruft"
551 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_CLEANUP)"
552 !insertmacro CleanUpFiles ""
553 SectionEnd
555 Section "!Install Files"
556 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_INSTFILES)"
558 DeleteOldBinary:
559 !insertmacro GetExecutableName $R0
560 ClearErrors
561 Delete "$INSTDIR\$R0"
563 ${If} ${Errors}
564 MessageBox MB_TOPMOST|MB_ICONSTOP|MB_RETRYCANCEL 'Could not delete old "$R0" file. Is LameXP still running?' IDRETRY DeleteOldBinary
565 Abort "Could not delete old binary!"
566 ${EndIf}
568 File /a `/oname=$R0` `${LAMEXP_SOURCE_PATH}\LameXP.exe`
569 File /nonfatal /a /r `${LAMEXP_SOURCE_PATH}\*.dll`
571 File /a /r `${LAMEXP_SOURCE_PATH}\*.txt`
572 File /a /r `${LAMEXP_SOURCE_PATH}\*.html`
573 File /a /r `${LAMEXP_SOURCE_PATH}\*.png`
574 SectionEnd
576 # Section "-Install VCRedist"
577 # !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_VCREDIST)"
578 # File /a `/oname=$PLUGINSDIR\vcredist_x86.exe` `${LAMEXP_SOURCE_PATH}\redist\vcredist_x86.exe`
579 # ExecWait '"$PLUGINSDIR\vcredist_x86.exe" /install /passive /norestart'
580 # SectionEnd
582 Section "-Write Uninstaller"
583 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_MAKEUNINST)"
584 WriteUninstaller "$INSTDIR\Uninstall.exe"
585 SectionEnd
587 Section "-Create Shortcuts"
588 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
589 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_SHORTCUTS)"
590 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
592 SetShellVarContext current
594 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
595 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
596 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
598 SetShellVarContext all
600 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
601 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
602 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
604 !insertmacro GetExecutableName $R0
606 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" "$INSTDIR\$R0" "" "$INSTDIR\$R0" 0
607 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_LICENSE).lnk" "$INSTDIR\License.txt"
608 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_CHANGELOG).lnk" "$INSTDIR\Changelog.html"
609 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_TRANSLATE).lnk" "$INSTDIR\Translate.html"
610 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_MANUAL).lnk" "$INSTDIR\Manual.html"
611 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(LAMEXP_LANG_LINK_UNINSTALL).lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
613 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Official LameXP Homepage.url" "${MyWebSite}"
614 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Doom9's Forum.url" "http://forum.doom9.org/"
615 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Bug Tracker.url" "https://github.com/lordmulder/LameXP/issues"
616 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\RareWares.org.url" "http://rarewares.org/"
617 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Hydrogenaudio Forums.url" "http://www.hydrogenaudio.org/"
619 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"
620 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "LameXP.lnk" ${StdUtils.Const.ShellVerb.PinToTaskbar}
621 DetailPrint 'Pin: "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" -> $R1'
622 ${EndIf}
623 !insertmacro MUI_STARTMENU_WRITE_END
624 SectionEnd
626 Section "-Update Registry"
627 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_REGISTRY)"
629 !insertmacro GetExecutableName $R0
630 WriteRegStr HKLM "${MyRegPath}" "InstallLocation" "$INSTDIR"
631 WriteRegStr HKLM "${MyRegPath}" "ExecutableName" "$R0"
632 WriteRegStr HKLM "${MyRegPath}" "DisplayIcon" "$INSTDIR\$R0,0"
633 WriteRegStr HKLM "${MyRegPath}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
634 WriteRegStr HKLM "${MyRegPath}" "DisplayName" "LameXP v${LAMEXP_VERSION}"
635 WriteRegStr HKLM "${MyRegPath}" "Publisher" "LoRd_MuldeR <mulder2@gmx.de>"
636 WriteRegStr HKLM "${MyRegPath}" "DisplayVersion" "${LAMEXP_VERSION} ${LAMEXP_INSTTYPE}-${LAMEXP_PATCH} [Build #${LAMEXP_BUILD}]"
637 WriteRegStr HKLM "${MyRegPath}" "URLInfoAbout" "${MyWebSite}"
638 WriteRegStr HKLM "${MyRegPath}" "URLUpdateInfo" "${MyWebSite}"
640 DeleteRegKey HKCU "${AppPaths}\LameXP.exe"
641 WriteRegStr HKLM "${AppPaths}\LameXP.exe" "" "$INSTDIR\$R0"
642 WriteRegStr HKLM "${AppPaths}\LameXP.exe" "Path" "$INSTDIR"
643 SectionEnd
645 Section "-Finished"
646 !insertmacro PrintProgress "$(MUI_TEXT_FINISH_TITLE)."
648 !ifdef LAMEXP_IS_PRERELEASE
649 ${If} ${FileExists} "$INSTDIR\PRE_RELEASE_INFO.txt"
650 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\PRE_RELEASE_INFO.txt" "open" ""
651 ${EndIf}
652 !endif
654 ${IfThen} ${UnattendedMode} ${|} SetAutoClose true ${|}
655 SectionEnd
658 ;--------------------------------
659 ;Uninstaller
660 ;--------------------------------
662 Section "Uninstall"
663 SetOutPath "$EXEDIR"
664 !insertmacro PrintProgress "$(LAMEXP_LANG_STATUS_UNINSTALL)"
666 ; --------------
667 ; Startmenu
668 ; --------------
670 !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
671 ${IfNot} "$StartMenuFolder" == ""
672 SetShellVarContext current
673 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"
674 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "LameXP.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
675 DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" -> $R1'
676 ${EndIf}
677 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
678 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
679 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
680 RMDir "$SMPROGRAMS\$StartMenuFolder"
681 ${EndIf}
683 SetShellVarContext all
684 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk"
685 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "LameXP.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
686 DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\LameXP.lnk" -> $R1'
687 ${EndIf}
688 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
689 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
690 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
691 RMDir "$SMPROGRAMS\$StartMenuFolder"
692 ${EndIf}
693 ${EndIf}
695 ; --------------
696 ; Files
697 ; --------------
699 ReadRegStr $R0 HKLM "${MyRegPath}" "ExecutableName"
700 ${IfThen} "$R0" == "" ${|} StrCpy $R0 "LameXP.exe" ${|}
701 ExecWait '"$INSTDIR\$R0" --uninstall'
703 Delete /REBOOTOK "$INSTDIR\$R0"
704 !insertmacro CleanUpFiles /REBOOTOK
705 RMDir "$INSTDIR"
707 ; --------------
708 ; Registry
709 ; --------------
711 DeleteRegKey HKLM "${MyRegPath}"
712 DeleteRegKey HKCU "${MyRegPath}"
714 DeleteRegKey HKLM "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
715 DeleteRegKey HKCU "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
717 DeleteRegKey HKLM "${AppPaths}\LameXP.exe"
718 DeleteRegKey HKCU "${AppPaths}\LameXP.exe"
720 MessageBox MB_YESNO|MB_TOPMOST "$(LAMEXP_LANG_UNINST_PERSONAL)" IDNO +3
721 Delete "$LOCALAPPDATA\LoRd_MuldeR\LameXP - Audio Encoder Front-End\config.ini"
722 Delete "$INSTDIR\*.ini"
724 !insertmacro PrintProgress "$(MUI_UNTEXT_FINISH_TITLE)."
725 SectionEnd
728 ;--------------------------------
729 ;Check For Update Mode
730 ;--------------------------------
732 Function SkipIfUnattended
733 ${IfThen} ${UnattendedMode} ${|} Abort ${|}
734 FunctionEnd
736 Function CheckForUpdate
737 ${If} "$INSTDIR" == ""
738 ${OrIf} "$INSTDIR" == "$EXEDIR"
739 ${OrIfNot} ${FileExists} "$INSTDIR\LameXP.exe"
740 Return
741 ${EndIf}
743 FindWindow $R0 "#32770" "" $HWNDPARENT
744 GetDlgItem $R1 $R0 1019
745 EnableWindow $R1 0
747 FindWindow $R0 "#32770" "" $HWNDPARENT
748 GetDlgItem $R1 $R0 1001
749 EnableWindow $R1 0
750 FunctionEnd
752 Function un.CheckForcedUninstall
753 ${IfThen} ${ForcedMode} ${|} Abort ${|}
754 FunctionEnd
757 ;--------------------------------
758 ;Check For Pre-Release
759 ;--------------------------------
761 Function CheckForPreRelease
762 !ifdef LAMEXP_IS_PRERELEASE
763 ${IfNot} ${UnattendedMode}
764 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION|MB_OKCANCEL "$(LAMEXP_LANG_PRERELEASE_WARNING)" /SD IDOK IDOK +2
765 Quit
766 ${EndIf}
767 !endif
768 FunctionEnd
771 ;--------------------------------
772 ;Locked List
773 ;--------------------------------
775 !macro _LockedListShow uinst
776 !insertmacro MUI_HEADER_TEXT "$(LAMEXP_LANG_LOCKEDLIST_HEADER)" "$(LAMEXP_LANG_LOCKEDLIST_TEXT)"
777 ${If} ${UnattendedMode}
778 !insertmacro DisableBackButton $R0
779 ${EndIf}
780 ${If} ${RunningX64}
781 InitPluginsDir
782 File /oname=$PLUGINSDIR\LockedList64.dll `${NSISDIR}\Plugins\LockedList64.dll`
783 ${EndIf}
784 !insertmacro GetExecutableName $R0
785 LockedList::AddModule "\$R0"
786 ${If} "$R0" != "LameXP.exe"
787 LockedList::AddModule "\LameXP.exe"
788 ${EndIf}
789 LockedList::AddModule "\Uninstall.exe"
790 !if ${uinst} < 1
791 LockedList::AddModule "\Au_.exe"
792 !endif
793 #LockedList::AddFolder "$INSTDIR"
794 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)"
795 Pop $R0
796 !macroend
798 Function LockedListShow
799 !insertmacro _LockedListShow 0
800 FunctionEnd
802 Function un.LockedListShow
803 !insertmacro _LockedListShow 1
804 FunctionEnd
807 ;--------------------------------
808 ;Install Success
809 ;--------------------------------
811 Function RunAppFunction
812 !insertmacro DisableNextButton $R0
813 !insertmacro GetExecutableName $R0
814 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR" "explore" ""
815 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\$R0" "open" "--first-run"
816 FunctionEnd
818 Function ShowReadmeFunction
819 !insertmacro DisableNextButton $R0
820 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\Manual.html" "open" ""
821 FunctionEnd
823 Function .onInstSuccess
824 ${If} ${UnattendedMode}
825 !insertmacro GetExecutableName $R0
826 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\$R0" "open" "--first-run"
827 ${EndIf}
828 FunctionEnd