Backported various installer improvements from LameXP installer.
[simple-x264-launcher.git] / etc / setup / setup.nsi
blobade5b90c37ea2779d524eb6afdc313bac982c282
1 ; ///////////////////////////////////////////////////////////////////////////////
2 ; // Simple x264 Launcher
3 ; // Copyright (C) 2004-2015 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 X264_BUILD
32 !error "X264_BUILD is not defined !!!"
33 !endif
34 !ifndef X264_DATE
35 !error "X264_DATE is not defined !!!"
36 !endif
37 !ifndef X264_OUTPUT_FILE
38 !error "X264_OUTPUT_FILE is not defined !!!"
39 !endif
40 !ifndef X264_SOURCE_PATH
41 !error "X264_SOURCE_PATH is not defined !!!"
42 !endif
43 !ifndef X264_UPX_PATH
44 !error "X264_UPX_PATH is not defined !!!"
45 !endif
47 ;UUID
48 !define MyRegPath "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{986E454F-DACA-4326-A9C7-3E46C0BFFDCE}"
50 ;Web-Site
51 !define MyWebSite "http://muldersoft.com/"
54 ;--------------------------------
55 ;Manifest
56 ;--------------------------------
58 !tempfile PACKHDRTEMP
59 !packhdr "${PACKHDRTEMP}" '"..\mt.exe" -manifest "setup.manifest" -outputresource:"${PACKHDRTEMP};1"'
62 ;--------------------------------
63 ;Includes
64 ;--------------------------------
66 !include `MUI2.nsh`
67 !include `WinVer.nsh`
68 !include `x64.nsh`
69 !include `StdUtils.nsh`
72 ;--------------------------------
73 ;Installer Attributes
74 ;--------------------------------
76 RequestExecutionLevel admin
77 ShowInstDetails show
78 ShowUninstDetails show
79 Name "Simple x264/x265 Launcher [Build #${X264_BUILD}]"
80 OutFile "${X264_OUTPUT_FILE}"
81 BrandingText "Date created: ${X264_DATE} [Build #${X264_BUILD}]"
82 InstallDir "$PROGRAMFILES\MuldeR\Simple x264 Launcher v2"
83 InstallDirRegKey HKLM "${MyRegPath}" "InstallLocation"
86 ;--------------------------------
87 ;Compressor
88 ;--------------------------------
90 SetCompressor /SOLID LZMA
91 SetCompressorDictSize 64
93 #!packhdr "$%TEMP%\exehead.tmp" '"${X264_UPX_PATH}\upx.exe" --brute "$%TEMP%\exehead.tmp"'
96 ;--------------------------------
97 ;Reserved Files
98 ;--------------------------------
100 ReserveFile "${NSISDIR}\Plugins\Aero.dll"
101 ReserveFile "${NSISDIR}\Plugins\LangDLL.dll"
102 ReserveFile "${NSISDIR}\Plugins\LockedList.dll"
103 ReserveFile "${NSISDIR}\Plugins\nsDialogs.dll"
104 ReserveFile "${NSISDIR}\Plugins\nsExec.dll"
105 ReserveFile "${NSISDIR}\Plugins\StartMenu.dll"
106 ReserveFile "${NSISDIR}\Plugins\StdUtils.dll"
107 ReserveFile "${NSISDIR}\Plugins\System.dll"
108 ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
111 ;--------------------------------
112 ;Variables
113 ;--------------------------------
115 Var StartMenuFolder
118 ;--------------------------------
119 ;Version Info
120 ;--------------------------------
122 !searchreplace PRODUCT_VERSION_DATE "${X264_DATE}" "-" "."
123 VIProductVersion "${PRODUCT_VERSION_DATE}.${X264_BUILD}"
125 VIAddVersionKey "Author" "LoRd_MuldeR <mulder2@gmx.de>"
126 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."
127 VIAddVersionKey "CompanyName" "Free Software Foundation"
128 VIAddVersionKey "FileDescription" "Simple x264 Launcher [Build #${X264_BUILD}]"
129 VIAddVersionKey "FileVersion" "${PRODUCT_VERSION_DATE}.${X264_BUILD}"
130 VIAddVersionKey "LegalCopyright" "Copyright 2004-2015 LoRd_MuldeR"
131 VIAddVersionKey "LegalTrademarks" "GNU"
132 VIAddVersionKey "OriginalFilename" "x264_x64.${X264_DATE}.exe"
133 VIAddVersionKey "ProductName" "Simple x264 Launcher"
134 VIAddVersionKey "ProductVersion" "Build #${X264_BUILD} (${X264_DATE})"
135 VIAddVersionKey "Website" "${MyWebSite}"
138 ;--------------------------------
139 ;MUI2 Interface Settings
140 ;--------------------------------
142 !define MUI_ABORTWARNING
143 !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
144 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${MyRegPath}"
145 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartmenuFolder"
146 !define MUI_LANGDLL_REGISTRY_ROOT HKLM
147 !define MUI_LANGDLL_REGISTRY_KEY "${MyRegPath}"
148 !define MUI_LANGDLL_REGISTRY_VALUENAME "SetupLanguage"
149 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "Simple x264 Launcher v2"
150 !define MUI_FINISHPAGE_NOAUTOCLOSE
151 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
152 !define MUI_FINISHPAGE_RUN
153 !define MUI_FINISHPAGE_RUN_FUNCTION RunAppFunction
154 !define MUI_FINISHPAGE_SHOWREADME
155 !define MUI_FINISHPAGE_SHOWREADME_FUNCTION ShowReadmeFunction
156 !define MUI_FINISHPAGE_LINK ${MyWebSite}
157 !define MUI_FINISHPAGE_LINK_LOCATION ${MyWebSite}
158 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
159 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"
160 !define MUI_WELCOMEFINISHPAGE_BITMAP "wizard.bmp"
161 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "wizard-un.bmp"
162 !define MUI_HEADERIMAGE
163 !define MUI_HEADERIMAGE_BITMAP "header.bmp"
164 !define MUI_HEADERIMAGE_UNBITMAP "header-un.bmp"
165 !define MUI_LANGDLL_ALLLANGUAGES
166 !define MUI_CUSTOMFUNCTION_GUIINIT MyGuiInit
167 !define MUI_CUSTOMFUNCTION_UNGUIINIT un.MyGuiInit
168 !define MUI_LANGDLL_ALWAYSSHOW
171 ;--------------------------------
172 ;MUI2 Pages (Installer)
173 ;--------------------------------
175 ;Welcome
176 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
177 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE CheckForPreRelease
178 !define MUI_WELCOMEPAGE_TITLE_3LINES
179 !define MUI_FINISHPAGE_TITLE_3LINES
180 !insertmacro MUI_PAGE_WELCOME
182 ;License
183 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
184 !insertmacro MUI_PAGE_LICENSE "license.rtf"
186 ;Directory
187 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
188 !define MUI_PAGE_CUSTOMFUNCTION_SHOW CheckForUpdate
189 !insertmacro MUI_PAGE_DIRECTORY
191 ;Startmenu
192 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
193 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
195 ;LockedList
196 Page Custom LockedListShow
198 ;Install Files
199 !insertmacro MUI_PAGE_INSTFILES
201 ;Finish
202 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
203 !insertmacro MUI_PAGE_FINISH
206 ;--------------------------------
207 ;MUI2 Pages (Uninstaller)
208 ;--------------------------------
210 ;Welcome
211 !define MUI_WELCOMEPAGE_TITLE_3LINES
212 !define MUI_FINISHPAGE_TITLE_3LINES
213 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
214 !insertmacro MUI_UNPAGE_WELCOME
216 ;Confirm
217 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
218 !insertmacro MUI_UNPAGE_CONFIRM
220 ;LockedList
221 UninstPage Custom un.LockedListShow
223 ;Uninstall
224 !insertmacro MUI_UNPAGE_INSTFILES
226 ;Finish
227 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
228 !insertmacro MUI_UNPAGE_FINISH
231 ;--------------------------------
232 ;Languages
233 ;--------------------------------
235 !insertmacro MUI_LANGUAGE "English" ;first language is the default language
237 ; !insertmacro MUI_LANGUAGE "German"
238 ; !insertmacro MUI_LANGUAGE "Spanish"
239 ; !insertmacro MUI_LANGUAGE "Russian"
240 ; !insertmacro MUI_LANGUAGE "Ukrainian"
241 ; !insertmacro MUI_LANGUAGE "Polish"
243 ; !insertmacro MUI_LANGUAGE "French"
244 ; !insertmacro MUI_LANGUAGE "SpanishInternational"
245 ; !insertmacro MUI_LANGUAGE "SimpChinese"
246 ; !insertmacro MUI_LANGUAGE "TradChinese"
247 ; !insertmacro MUI_LANGUAGE "Japanese"
248 ; !insertmacro MUI_LANGUAGE "Italian"
249 ; !insertmacro MUI_LANGUAGE "Dutch"
250 ; !insertmacro MUI_LANGUAGE "Greek"
251 ; !insertmacro MUI_LANGUAGE "Hungarian"
252 ; !insertmacro MUI_LANGUAGE "Romanian"
253 ; !insertmacro MUI_LANGUAGE "Serbian"
254 ; !insertmacro MUI_LANGUAGE "SerbianLatin"
255 ; !insertmacro MUI_LANGUAGE "Arabic"
256 ; !insertmacro MUI_LANGUAGE "Portuguese"
257 ; !insertmacro MUI_LANGUAGE "Afrikaans"
258 ; !insertmacro MUI_LANGUAGE "Malay"
259 ; !insertmacro MUI_LANGUAGE "Indonesian"
262 ;--------------------------------
263 ;Translation
264 ;--------------------------------
266 ;English
267 !include "language\en.nsh"
270 ;--------------------------------
271 ;LogicLib Extensions
272 ;--------------------------------
274 !macro _UnattendedMode _a _b _t _f
275 !insertmacro _LOGICLIB_TEMP
276 ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Update"
277 StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
278 !macroend
279 !define UnattendedMode `"" UnattendedMode ""`
281 !macro _ForcedMode _a _b _t _f
282 !insertmacro _LOGICLIB_TEMP
283 ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Force"
284 StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
285 !macroend
286 !define ForcedMode `"" ForcedMode ""`
288 !macro _ValidFileName _a _b _t _f
289 !insertmacro _LOGICLIB_TEMP
290 ${StdUtils.ValidFileName} $_LOGICLIB_TEMP `${_b}`
291 StrCmp "$_LOGICLIB_TEMP" "ok" `${_t}` `${_f}`
292 !macroend
293 !define ValidFileName `"" ValidFileName`
296 ;--------------------------------
297 ;Installer initialization
298 ;--------------------------------
300 Function .onInit
301 InitPluginsDir
303 ; --------
305 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
306 Pop $0
307 ${If} $0 <> 0
308 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the installer is already running!"
309 Quit
310 ${EndIf}
312 ; --------
314 # Running on Windows NT family?
315 ${IfNot} ${IsNT}
316 MessageBox MB_TOPMOST|MB_ICONSTOP "Sorry, this application does *not* support Windows 9x or Windows ME!"
317 ExecShell "open" "http://windows.microsoft.com/"
318 Quit
319 ${EndIf}
321 # Running on Windows XP or later?
322 ${If} ${AtMostWin2000}
323 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)."
324 ExecShell "open" "http://windows.microsoft.com/"
325 Quit
326 ${EndIf}
328 # If on Windows XP, is the required Service Pack installed?
329 ${If} ${IsWinXP}
330 ${IfNot} ${RunningX64} # Windows XP 32-Bit, requires Service Pack 3
331 ${AndIf} ${AtMostServicePack} 2
332 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Windows XP with Service Pack 3 installed.$\nWindows XP *without* Service Pack 3 reached end-of-life on 2010-07-13.$\nCurrent Windows XP (Service Pack 3) will be supported until 2014-04-08.$\n$\nPlease install Service Pack 3 now or just run Windows Update!"
333 ${If} ${Cmd} `MessageBox MB_TOPMOST|MB_ICONQUESTION|MB_YESNO "Do you want to download Service Pack 3 for Windows XP now?" IDYES`
334 ExecShell "open" "http://www.microsoft.com/en-us/download/details.aspx?id=24"
335 ${Else}
336 ExecShell "open" "http://windowsupdate.microsoft.com/"
337 ${EndIf}
338 Quit
339 ${EndIf}
340 ${If} ${RunningX64} # Windows XP 64-Bit, requires Service Pack 2
341 ${AndIf} ${AtMostServicePack} 1
342 MessageBox MB_TOPMOST|MB_ICONEXCLAMATION "This application requires Windows XP x64 Edition with Service Pack 2 installed.$\nWindows XP x64 Edition *without* Service Pack 2 reached end-of-life on 2009-04-14.$\nCurrent Windows XP x64 Edition (Service Pack 2) will be supported until 2014-04-08.$\n$\nPlease install Service Pack 2 now or just run Windows Update!"
343 ${If} ${Cmd} `MessageBox MB_TOPMOST|MB_ICONQUESTION|MB_YESNO "Do you want to download Service Pack 2 for Windows XP x64 Edition now?" IDYES`
344 ExecShell "open" "http://www.microsoft.com/en-us/download/details.aspx?id=17791"
345 ${Else}
346 ExecShell "open" "http://windowsupdate.microsoft.com/"
347 ${EndIf}
348 Quit
349 ${EndIf}
350 ${EndIf}
352 ; --------
354 ${IfNot} ${UnattendedMode}
355 !insertmacro MUI_LANGDLL_DISPLAY
356 ${EndIf}
358 ; --------
360 UserInfo::GetAccountType
361 Pop $0
362 ${If} $0 != "Admin"
363 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
364 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
365 Quit
366 ${EndIf}
367 FunctionEnd
369 Function un.onInit
370 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
371 Pop $0
372 ${If} $0 <> 0
373 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the un-installer is already running!"
374 Quit
375 ${EndIf}
377 ${IfNot} ${ForcedMode}
378 !insertmacro MUI_LANGDLL_DISPLAY
379 ${EndIf}
381 ; --------
383 UserInfo::GetAccountType
384 Pop $0
385 ${If} $0 != "Admin"
386 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
387 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
388 Quit
389 ${EndIf}
390 FunctionEnd
393 ;--------------------------------
394 ;GUI initialization
395 ;--------------------------------
397 Function MyGuiInit
398 StrCpy $0 $HWNDPARENT
399 System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
400 Aero::Apply
401 FunctionEnd
403 Function un.MyGuiInit
404 StrCpy $0 $HWNDPARENT
405 System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
406 Aero::Apply
407 FunctionEnd
410 ;--------------------------------
411 ;Macros & Auxiliary Functions
412 ;--------------------------------
414 !macro PrintProgress Text
415 SetDetailsPrint textonly
416 DetailPrint '${Text}'
417 SetDetailsPrint listonly
418 Sleep 1000
419 !macroend
421 !macro CreateWebLink ShortcutFile TargetURL
422 Push $0
423 Push $1
424 StrCpy $0 "${ShortcutFile}"
425 StrCpy $1 "${TargetURL}"
426 Call _CreateWebLink
427 Pop $1
428 Pop $0
429 !macroend
431 Function _CreateWebLink
432 FlushINI "$0"
433 SetFileAttributes "$0" FILE_ATTRIBUTE_NORMAL
434 DeleteINISec "$0" "DEFAULT"
435 DeleteINISec "$0" "InternetShortcut"
436 WriteINIStr "$0" "DEFAULT" "BASEURL" "$1"
437 WriteINIStr "$0" "InternetShortcut" "ORIGURL" "$1"
438 WriteINIStr "$0" "InternetShortcut" "URL" "$1"
439 WriteINIStr "$0" "InternetShortcut" "IconFile" "$SYSDIR\SHELL32.dll"
440 WriteINIStr "$0" "InternetShortcut" "IconIndex" "150"
441 FlushINI "$0"
442 SetFileAttributes "$0" FILE_ATTRIBUTE_READONLY
443 FunctionEnd
445 !macro GetExecutableName OutVar
446 ${StdUtils.GetParameter} ${OutVar} "Update" ""
447 ${StdUtils.TrimStr} ${OutVar}
448 ${If} "${OutVar}" == ""
449 ${OrIfNot} ${ValidFileName} "${OutVar}"
450 StrCpy ${OutVar} "x264_launcher.exe"
451 ${EndIf}
452 !macroend
454 !macro DisableNextButton TmpVar
455 GetDlgItem ${TmpVar} $HWNDPARENT 1
456 EnableWindow ${TmpVar} 0
457 !macroend
459 !macro CleanUpFiles options
460 Delete ${options} `$INSTDIR\*.exe`
461 Delete ${options} `$INSTDIR\*.dll`
462 Delete ${options} `$INSTDIR\*.txt`
463 Delete ${options} `$INSTDIR\*.html`
465 RMDir /r ${options} `$INSTDIR\toolset`
466 RMDir /r ${options} `$INSTDIR\imageformats`
467 RMDir /r ${options} `$INSTDIR\sources`
468 !macroend
471 ;--------------------------------
472 ;Install Files
473 ;--------------------------------
475 Section "-PreInit"
476 SetShellVarContext all
477 SetOutPath "$INSTDIR"
478 SectionEnd
480 Section "-Clean Up Old Cruft"
481 !insertmacro PrintProgress "$(X264_LANG_STATUS_CLEANUP)"
482 !insertmacro CleanUpFiles ""
483 SectionEnd
485 Section "!Install Files"
486 !insertmacro PrintProgress "$(X264_LANG_STATUS_INSTFILES)"
488 DeleteOldBinary:
489 !insertmacro GetExecutableName $R0
490 ClearErrors
491 Delete "$INSTDIR\$R0"
493 ${If} ${Errors}
494 MessageBox MB_TOPMOST|MB_ICONSTOP|MB_RETRYCANCEL 'Could not delete old "$R0" file. Is program still running?' IDRETRY DeleteOldBinary
495 Abort "Could not delete old binary!"
496 ${EndIf}
498 SetOutPath "$INSTDIR"
499 File /a `/oname=$R0` `${X264_SOURCE_PATH}\x264_launcher.exe`
501 SetOutPath "$INSTDIR"
502 File /a `${X264_SOURCE_PATH}\*.dll`
503 File /a `${X264_SOURCE_PATH}\*.txt`
504 File /a `${X264_SOURCE_PATH}\*.html`
506 SetOutPath "$INSTDIR\imageformats"
507 File /a /r `${X264_SOURCE_PATH}\imageformats\*.*`
509 SetOutPath "$INSTDIR\toolset"
510 File /a /r `${X264_SOURCE_PATH}\toolset\*.*`
512 SetOutPath "$INSTDIR\sources"
513 File /a /r `${X264_SOURCE_PATH}\sources\*.*`
514 SectionEnd
516 Section "-Write Uinstaller"
517 !insertmacro PrintProgress "$(X264_LANG_STATUS_MAKEUNINST)"
518 WriteUninstaller "$INSTDIR\Uninstall.exe"
519 SectionEnd
521 Section "-Create Shortcuts"
522 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
523 !insertmacro PrintProgress "$(X264_LANG_STATUS_SHORTCUTS)"
524 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
526 SetShellVarContext current
528 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
529 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
530 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
532 SetShellVarContext all
534 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
535 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
536 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
538 !insertmacro GetExecutableName $R0
540 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk" "$INSTDIR\$R0" "" "$INSTDIR\$R0" 0
541 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(X264_LANG_LINK_LICENSE).lnk" "$INSTDIR\LICENSE.html"
542 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(X264_LANG_LINK_MANUAL).lnk" "$INSTDIR\README.html"
543 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(X264_LANG_LINK_CHANGELOG).lnk" "$INSTDIR\HISTORY.txt"
544 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(X264_LANG_LINK_UNINSTALL).lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
546 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\MuldeR's Homepage.url" "${MyWebSite}"
547 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Doom9's Forum.url" "http://forum.doom9.org/"
548 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\x264.com.url" "http://x264.com/"
549 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\x265.com.url" "http://x265.org/"
550 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Avisynth Wiki.url" "http://avisynth.nl/"
551 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\VapourSynth.com.url" "http://www.vapoursynth.com/"
553 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk"
554 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "Simple x264 Launcher.lnk" ${StdUtils.Const.ISV_PinToTaskbar}
555 DetailPrint 'Pin: "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk" -> $R1'
556 ${EndIf}
557 !insertmacro MUI_STARTMENU_WRITE_END
558 SectionEnd
560 Section "-Update Registry"
561 !insertmacro PrintProgress "$(X264_LANG_STATUS_REGISTRY)"
563 !insertmacro GetExecutableName $R0
564 WriteRegStr HKLM "${MyRegPath}" "InstallLocation" "$INSTDIR"
565 WriteRegStr HKLM "${MyRegPath}" "ExecutableName" "$R0"
566 WriteRegStr HKLM "${MyRegPath}" "DisplayIcon" "$INSTDIR\$R0,0"
567 WriteRegStr HKLM "${MyRegPath}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
568 WriteRegStr HKLM "${MyRegPath}" "DisplayName" "Simple x264 Launcher v2"
569 WriteRegStr HKLM "${MyRegPath}" "Publisher" "LoRd_MuldeR <mulder2@gmx.de>"
570 WriteRegStr HKLM "${MyRegPath}" "DisplayVersion" "Build #${X264_BUILD} (${X264_DATE})"
571 WriteRegStr HKLM "${MyRegPath}" "URLInfoAbout" "${MyWebSite}"
572 WriteRegStr HKLM "${MyRegPath}" "URLUpdateInfo" "${MyWebSite}"
574 WriteRegStr HKLM "${AppPaths}\x264_launcher.exe" "" "$INSTDIR\$R0"
575 WriteRegStr HKLM "${AppPaths}\x264_launcher.exe" "Path" "$INSTDIR"
576 SectionEnd
578 Section "-Finished"
579 !insertmacro PrintProgress "$(MUI_TEXT_FINISH_TITLE)."
580 SectionEnd
583 ;--------------------------------
584 ;Uninstaller
585 ;--------------------------------
587 Section "Uninstall"
588 SetOutPath "$EXEDIR"
589 !insertmacro PrintProgress "$(X264_LANG_STATUS_UNINSTALL)"
591 ; --------------
592 ; Startmenu
593 ; --------------
595 !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
596 ${IfNot} "$StartMenuFolder" == ""
597 SetShellVarContext current
598 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk"
599 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "Simple x264 Launcher.lnk" ${StdUtils.Const.ISV_UnpinFromTaskbar}
600 DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk" -> $R1'
601 ${EndIf}
602 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
603 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
604 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
605 RMDir "$SMPROGRAMS\$StartMenuFolder"
606 ${EndIf}
608 SetShellVarContext all
609 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk"
610 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "Simple x264 Launcher.lnk" ${StdUtils.Const.ISV_UnpinFromTaskbar}
611 DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk" -> $R1'
612 ${EndIf}
613 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
614 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
615 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
616 RMDir "$SMPROGRAMS\$StartMenuFolder"
617 ${EndIf}
618 ${EndIf}
620 ; --------------
621 ; Files
622 ; --------------
624 ReadRegStr $R0 HKLM "${MyRegPath}" "ExecutableName"
625 ${IfThen} "$R0" == "" ${|} StrCpy $R0 "x264_launcher.exe" ${|}
627 Delete /REBOOTOK "$INSTDIR\$R0"
628 !insertmacro CleanUpFiles /REBOOTOK
629 RMDir "$INSTDIR"
631 ; --------------
632 ; Registry
633 ; --------------
635 DeleteRegKey HKLM "${MyRegPath}"
636 DeleteRegKey HKCU "${MyRegPath}"
638 DeleteRegKey HKLM "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
639 DeleteRegKey HKCU "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
641 DeleteRegKey HKLM "${AppPaths}\x264_launcher.exe"
642 DeleteRegKey HKCU "${AppPaths}\x264_launcherexe"
644 MessageBox MB_YESNO|MB_TOPMOST "$(X264_LANG_UNINST_PERSONAL)" IDNO +3
645 Delete "$LOCALAPPDATA\LoRd_MuldeR\Simple x264 Launcher\*.ini"
646 RMDir "$LOCALAPPDATA\LoRd_MuldeR\Simple x264 Launcher"
648 !insertmacro PrintProgress "$(MUI_UNTEXT_FINISH_TITLE)."
649 SectionEnd
652 ;--------------------------------
653 ;Check For Update Mode
654 ;--------------------------------
656 Function SkipIfUnattended
657 ${IfThen} ${UnattendedMode} ${|} Abort ${|}
658 FunctionEnd
660 Function CheckForUpdate
661 ${If} "$INSTDIR" == ""
662 ${OrIf} "$INSTDIR" == "$EXEDIR"
663 ${OrIfNot} ${FileExists} "$INSTDIR\x264_launcher.exe"
664 Return
665 ${EndIf}
667 FindWindow $R0 "#32770" "" $HWNDPARENT
668 GetDlgItem $R1 $R0 1019
669 EnableWindow $R1 0
671 FindWindow $R0 "#32770" "" $HWNDPARENT
672 GetDlgItem $R1 $R0 1001
673 EnableWindow $R1 0
674 FunctionEnd
676 Function un.CheckForcedUninstall
677 ${IfThen} ${ForcedMode} ${|} Abort ${|}
678 FunctionEnd
681 ;--------------------------------
682 ;Locked List
683 ;--------------------------------
685 !macro _LockedListShow uinst
686 !insertmacro MUI_HEADER_TEXT "$(X264_LANG_LOCKEDLIST_HEADER)" "$(X264_LANG_LOCKEDLIST_TEXT)"
687 ${If} ${UnattendedMode}
688 !insertmacro DisableBackButton $R0
689 ${EndIf}
690 ${If} ${RunningX64}
691 InitPluginsDir
692 File /oname=$PLUGINSDIR\LockedList64.dll `${NSISDIR}\Plugins\LockedList64.dll`
693 ${EndIf}
694 !insertmacro GetExecutableName $R0
695 LockedList::AddModule "\$R0"
696 ${If} "$R0" != "x264_launcher.exe"
697 LockedList::AddModule "\x264_launcher.exe"
698 ${EndIf}
699 LockedList::AddModule "\Uninstall.exe"
700 !if ${uinst} < 1
701 LockedList::AddModule "\Au_.exe"
702 !endif
703 LockedList::AddFolder "$INSTDIR"
704 LockedList::Dialog /autonext /heading "$(X264_LANG_LOCKEDLIST_HEADING)" /noprograms "$(X264_LANG_LOCKEDLIST_NOPROG)" /searching "$(X264_LANG_LOCKEDLIST_SEARCH)" /colheadings "$(X264_LANG_LOCKEDLIST_COLHDR1)" "$(X264_LANG_LOCKEDLIST_COLHDR2)"
705 Pop $R0
706 !macroend
708 Function LockedListShow
709 !insertmacro _LockedListShow 0
710 FunctionEnd
712 Function un.LockedListShow
713 !insertmacro _LockedListShow 1
714 FunctionEnd
717 ;--------------------------------
718 ;Install Success
719 ;--------------------------------
721 Function RunAppFunction
722 !insertmacro DisableNextButton $R0
723 !insertmacro GetExecutableName $R0
724 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR" "explore" ""
725 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\$R0" "open" "--first-run"
726 FunctionEnd
728 Function ShowReadmeFunction
729 !insertmacro DisableNextButton $R0
730 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\README.html" "open" ""
731 FunctionEnd