Small installer fix.
[simple-x264-launcher.git] / etc / setup / setup.nsi
blobe0f78718924491fafdafce5d51c6a9a845554a14
1 ; ///////////////////////////////////////////////////////////////////////////////
2 ; // Simple x264 Launcher
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 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/"
53 ;App Paths
54 !define AppPaths "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"
57 ;--------------------------------
58 ;Manifest
59 ;--------------------------------
61 !tempfile PACKHDRTEMP
62 !packhdr "${PACKHDRTEMP}" '"..\mt.exe" -manifest "setup.manifest" -outputresource:"${PACKHDRTEMP};1"'
65 ;--------------------------------
66 ;Includes
67 ;--------------------------------
69 !include `MUI2.nsh`
70 !include `WinVer.nsh`
71 !include `x64.nsh`
72 !include `StdUtils.nsh`
75 ;--------------------------------
76 ;Installer Attributes
77 ;--------------------------------
79 RequestExecutionLevel admin
80 ShowInstDetails show
81 ShowUninstDetails show
82 Name "Simple x264/x265 Launcher [Build #${X264_BUILD}]"
83 OutFile "${X264_OUTPUT_FILE}"
84 BrandingText "Date created: ${X264_DATE} [Build #${X264_BUILD}]"
85 InstallDir "$PROGRAMFILES\MuldeR\Simple x264 Launcher v2"
86 InstallDirRegKey HKLM "${MyRegPath}" "InstallLocation"
89 ;--------------------------------
90 ;Compressor
91 ;--------------------------------
93 SetCompressor /SOLID LZMA
94 SetCompressorDictSize 64
96 !packhdr "$%TEMP%\exehead.tmp" '"${X264_UPX_PATH}" --brute "$%TEMP%\exehead.tmp"'
99 ;--------------------------------
100 ;Reserved Files
101 ;--------------------------------
103 ReserveFile "${NSISDIR}\Plugins\Aero.dll"
104 ReserveFile "${NSISDIR}\Plugins\LangDLL.dll"
105 ReserveFile "${NSISDIR}\Plugins\LockedList.dll"
106 ReserveFile "${NSISDIR}\Plugins\LockedList64.dll"
107 ReserveFile "${NSISDIR}\Plugins\nsDialogs.dll"
108 ReserveFile "${NSISDIR}\Plugins\nsExec.dll"
109 ReserveFile "${NSISDIR}\Plugins\StartMenu.dll"
110 ReserveFile "${NSISDIR}\Plugins\StdUtils.dll"
111 ReserveFile "${NSISDIR}\Plugins\System.dll"
112 ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
115 ;--------------------------------
116 ;Variables
117 ;--------------------------------
119 Var StartMenuFolder
120 Var UpdateNotificationShown
123 ;--------------------------------
124 ;Version Info
125 ;--------------------------------
127 !searchreplace PRODUCT_VERSION_DATE "${X264_DATE}" "-" "."
128 VIProductVersion "${PRODUCT_VERSION_DATE}.${X264_BUILD}"
130 VIAddVersionKey "Author" "LoRd_MuldeR <mulder2@gmx.de>"
131 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."
132 VIAddVersionKey "CompanyName" "Free Software Foundation"
133 VIAddVersionKey "FileDescription" "Simple x264 Launcher [Build #${X264_BUILD}]"
134 VIAddVersionKey "FileVersion" "${PRODUCT_VERSION_DATE}.${X264_BUILD}"
135 VIAddVersionKey "LegalCopyright" "Copyright 2004-2016 LoRd_MuldeR"
136 VIAddVersionKey "LegalTrademarks" "GNU"
137 VIAddVersionKey "OriginalFilename" "x264_x64.${X264_DATE}.exe"
138 VIAddVersionKey "ProductName" "Simple x264 Launcher"
139 VIAddVersionKey "ProductVersion" "Build #${X264_BUILD} (${X264_DATE})"
140 VIAddVersionKey "Website" "${MyWebSite}"
143 ;--------------------------------
144 ;MUI2 Interface Settings
145 ;--------------------------------
147 !define MUI_ABORTWARNING
148 !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
149 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${MyRegPath}"
150 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "StartmenuFolder"
151 !define MUI_LANGDLL_REGISTRY_ROOT HKLM
152 !define MUI_LANGDLL_REGISTRY_KEY "${MyRegPath}"
153 !define MUI_LANGDLL_REGISTRY_VALUENAME "SetupLanguage"
154 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "Simple x264 Launcher v2"
155 !define MUI_FINISHPAGE_NOAUTOCLOSE
156 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
157 !define MUI_FINISHPAGE_RUN
158 !define MUI_FINISHPAGE_RUN_FUNCTION RunAppFunction
159 !define MUI_FINISHPAGE_SHOWREADME
160 !define MUI_FINISHPAGE_SHOWREADME_FUNCTION ShowReadmeFunction
161 !define MUI_FINISHPAGE_LINK ${MyWebSite}
162 !define MUI_FINISHPAGE_LINK_LOCATION ${MyWebSite}
163 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
164 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"
165 !define MUI_WELCOMEFINISHPAGE_BITMAP "wizard.bmp"
166 !define MUI_UNWELCOMEFINISHPAGE_BITMAP "wizard-un.bmp"
167 !define MUI_HEADERIMAGE
168 !define MUI_HEADERIMAGE_BITMAP "header.bmp"
169 !define MUI_HEADERIMAGE_UNBITMAP "header-un.bmp"
170 !define MUI_LANGDLL_ALLLANGUAGES
171 !define MUI_CUSTOMFUNCTION_GUIINIT MyGuiInit
172 !define MUI_CUSTOMFUNCTION_UNGUIINIT un.MyGuiInit
173 !define MUI_LANGDLL_ALWAYSSHOW
176 ;--------------------------------
177 ;MUI2 Pages (Installer)
178 ;--------------------------------
180 ;Welcome
181 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
182 !define MUI_WELCOMEPAGE_TITLE_3LINES
183 !define MUI_FINISHPAGE_TITLE_3LINES
184 !insertmacro MUI_PAGE_WELCOME
186 ;License
187 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
188 !insertmacro MUI_PAGE_LICENSE "license.rtf"
190 ;Directory
191 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
192 !define MUI_PAGE_CUSTOMFUNCTION_SHOW CheckForUpdate
193 !insertmacro MUI_PAGE_DIRECTORY
195 ;Startmenu
196 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
197 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
199 ;LockedList
200 Page Custom LockedListShow
202 ;Install Files
203 !insertmacro MUI_PAGE_INSTFILES
205 ;Finish
206 !define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUnattended
207 !insertmacro MUI_PAGE_FINISH
210 ;--------------------------------
211 ;MUI2 Pages (Uninstaller)
212 ;--------------------------------
214 ;Welcome
215 !define MUI_WELCOMEPAGE_TITLE_3LINES
216 !define MUI_FINISHPAGE_TITLE_3LINES
217 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
218 !insertmacro MUI_UNPAGE_WELCOME
220 ;Confirm
221 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
222 !insertmacro MUI_UNPAGE_CONFIRM
224 ;LockedList
225 UninstPage Custom un.LockedListShow
227 ;Uninstall
228 !insertmacro MUI_UNPAGE_INSTFILES
230 ;Finish
231 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.CheckForcedUninstall
232 !insertmacro MUI_UNPAGE_FINISH
235 ;--------------------------------
236 ;Languages
237 ;--------------------------------
239 !insertmacro MUI_LANGUAGE "English" ;first language is the default language
241 ; !insertmacro MUI_LANGUAGE "German"
242 ; !insertmacro MUI_LANGUAGE "Spanish"
243 ; !insertmacro MUI_LANGUAGE "Russian"
244 ; !insertmacro MUI_LANGUAGE "Ukrainian"
245 ; !insertmacro MUI_LANGUAGE "Polish"
247 ; !insertmacro MUI_LANGUAGE "French"
248 ; !insertmacro MUI_LANGUAGE "SpanishInternational"
249 ; !insertmacro MUI_LANGUAGE "SimpChinese"
250 ; !insertmacro MUI_LANGUAGE "TradChinese"
251 ; !insertmacro MUI_LANGUAGE "Japanese"
252 ; !insertmacro MUI_LANGUAGE "Italian"
253 ; !insertmacro MUI_LANGUAGE "Dutch"
254 ; !insertmacro MUI_LANGUAGE "Greek"
255 ; !insertmacro MUI_LANGUAGE "Hungarian"
256 ; !insertmacro MUI_LANGUAGE "Romanian"
257 ; !insertmacro MUI_LANGUAGE "Serbian"
258 ; !insertmacro MUI_LANGUAGE "SerbianLatin"
259 ; !insertmacro MUI_LANGUAGE "Arabic"
260 ; !insertmacro MUI_LANGUAGE "Portuguese"
261 ; !insertmacro MUI_LANGUAGE "Afrikaans"
262 ; !insertmacro MUI_LANGUAGE "Malay"
263 ; !insertmacro MUI_LANGUAGE "Indonesian"
266 ;--------------------------------
267 ;Translation
268 ;--------------------------------
270 ;English
271 !include "language\en.nsh"
274 ;--------------------------------
275 ;LogicLib Extensions
276 ;--------------------------------
278 !macro _UnattendedMode _a _b _t _f
279 !insertmacro _LOGICLIB_TEMP
280 ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Update"
281 StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
282 !macroend
283 !define UnattendedMode `"" UnattendedMode ""`
285 !macro _ForcedMode _a _b _t _f
286 !insertmacro _LOGICLIB_TEMP
287 ${StdUtils.TestParameter} $_LOGICLIB_TEMP "Force"
288 StrCmp "$_LOGICLIB_TEMP" "true" `${_t}` `${_f}`
289 !macroend
290 !define ForcedMode `"" ForcedMode ""`
292 !macro _ValidFileName _a _b _t _f
293 !insertmacro _LOGICLIB_TEMP
294 ${StdUtils.ValidFileName} $_LOGICLIB_TEMP `${_b}`
295 StrCmp "$_LOGICLIB_TEMP" "ok" `${_t}` `${_f}`
296 !macroend
297 !define ValidFileName `"" ValidFileName`
300 ;--------------------------------
301 ;Installer initialization
302 ;--------------------------------
304 Function .onInit
305 InitPluginsDir
307 ; --------
309 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
310 Pop $0
311 ${If} $0 <> 0
312 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the installer is already running!"
313 Quit
314 ${EndIf}
316 ; --------
318 # Running on Windows NT family?
319 ${IfNot} ${IsNT}
320 MessageBox MB_TOPMOST|MB_ICONSTOP "Sorry, this application does *not* support Windows 9x or Windows ME!"
321 ExecShell "open" "http://windows.microsoft.com/"
322 Quit
323 ${EndIf}
325 # Running on Windows XP or later?
326 ${If} ${AtMostWin2000}
327 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)."
328 ExecShell "open" "http://windows.microsoft.com/"
329 Quit
330 ${EndIf}
332 # If on Windows XP, is the required Service Pack installed?
333 ${If} ${IsWinXP}
334 ${IfNot} ${RunningX64} # Windows XP 32-Bit, requires Service Pack 3
335 ${AndIf} ${AtMostServicePack} 2
336 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!"
337 ${If} ${Cmd} `MessageBox MB_TOPMOST|MB_ICONQUESTION|MB_YESNO "Do you want to download Service Pack 3 for Windows XP now?" IDYES`
338 ExecShell "open" "http://www.microsoft.com/en-us/download/details.aspx?id=24"
339 ${Else}
340 ExecShell "open" "http://windowsupdate.microsoft.com/"
341 ${EndIf}
342 Quit
343 ${EndIf}
344 ${If} ${RunningX64} # Windows XP 64-Bit, requires Service Pack 2
345 ${AndIf} ${AtMostServicePack} 1
346 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!"
347 ${If} ${Cmd} `MessageBox MB_TOPMOST|MB_ICONQUESTION|MB_YESNO "Do you want to download Service Pack 2 for Windows XP x64 Edition now?" IDYES`
348 ExecShell "open" "http://www.microsoft.com/en-us/download/details.aspx?id=17791"
349 ${Else}
350 ExecShell "open" "http://windowsupdate.microsoft.com/"
351 ${EndIf}
352 Quit
353 ${EndIf}
354 ${EndIf}
356 ; --------
358 ${IfNot} ${UnattendedMode}
359 !insertmacro MUI_LANGDLL_DISPLAY
360 ${EndIf}
362 ; --------
364 UserInfo::GetAccountType
365 Pop $0
366 ${If} $0 != "Admin"
367 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
368 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
369 Quit
370 ${EndIf}
371 FunctionEnd
373 Function un.onInit
374 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "{2B3D1EBF-B3B6-4E93-92B9-6853029A7162}") i .r1 ?e'
375 Pop $0
376 ${If} $0 <> 0
377 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the un-installer is already running!"
378 Quit
379 ${EndIf}
381 ${IfNot} ${ForcedMode}
382 !insertmacro MUI_LANGDLL_DISPLAY
383 ${EndIf}
385 ; --------
387 UserInfo::GetAccountType
388 Pop $0
389 ${If} $0 != "Admin"
390 MessageBox MB_ICONSTOP|MB_TOPMOST "Your system requires administrative permissions in order to install this software."
391 SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
392 Quit
393 ${EndIf}
394 FunctionEnd
397 ;--------------------------------
398 ;GUI initialization
399 ;--------------------------------
401 Function MyGuiInit
402 StrCpy $0 $HWNDPARENT
403 System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
404 Aero::Apply
405 FunctionEnd
407 Function un.MyGuiInit
408 StrCpy $0 $HWNDPARENT
409 System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
410 Aero::Apply
411 FunctionEnd
414 ;--------------------------------
415 ;Macros & Auxiliary Functions
416 ;--------------------------------
418 !macro PrintProgress Text
419 SetDetailsPrint textonly
420 DetailPrint '${Text}'
421 SetDetailsPrint listonly
422 Sleep 1000
423 !macroend
425 !macro CreateWebLink ShortcutFile TargetURL
426 Push $0
427 Push $1
428 StrCpy $0 "${ShortcutFile}"
429 StrCpy $1 "${TargetURL}"
430 Call _CreateWebLink
431 Pop $1
432 Pop $0
433 !macroend
435 Function _CreateWebLink
436 FlushINI "$0"
437 SetFileAttributes "$0" FILE_ATTRIBUTE_NORMAL
438 DeleteINISec "$0" "DEFAULT"
439 DeleteINISec "$0" "InternetShortcut"
440 WriteINIStr "$0" "DEFAULT" "BASEURL" "$1"
441 WriteINIStr "$0" "InternetShortcut" "ORIGURL" "$1"
442 WriteINIStr "$0" "InternetShortcut" "URL" "$1"
443 WriteINIStr "$0" "InternetShortcut" "IconFile" "$SYSDIR\SHELL32.dll"
444 WriteINIStr "$0" "InternetShortcut" "IconIndex" "150"
445 FlushINI "$0"
446 SetFileAttributes "$0" FILE_ATTRIBUTE_READONLY
447 FunctionEnd
449 !macro GetExecutableName OutVar
450 ${StdUtils.GetParameter} ${OutVar} "Update" ""
451 ${StdUtils.TrimStr} ${OutVar}
452 ${If} "${OutVar}" == ""
453 ${OrIfNot} ${ValidFileName} "${OutVar}"
454 StrCpy ${OutVar} "x264_launcher.exe"
455 ${EndIf}
456 !macroend
458 !macro DisableNextButton TmpVar
459 GetDlgItem ${TmpVar} $HWNDPARENT 1
460 EnableWindow ${TmpVar} 0
461 !macroend
463 !macro DisableBackButton TmpVar
464 GetDlgItem ${TmpVar} $HWNDPARENT 3
465 EnableWindow ${TmpVar} 0
466 !macroend
468 !macro CleanUpFiles options
469 Delete ${options} `$INSTDIR\*.exe`
470 Delete ${options} `$INSTDIR\*.dll`
471 Delete ${options} `$INSTDIR\*.txt`
472 Delete ${options} `$INSTDIR\*.htm`
473 Delete ${options} `$INSTDIR\*.html`
475 RMDir /r ${options} `$INSTDIR\toolset`
476 RMDir /r ${options} `$INSTDIR\imageformats`
477 RMDir /r ${options} `$INSTDIR\sources`
478 !macroend
480 !macro SetControlEnabled item_id enable
481 FindWindow $R0 "#32770" "" $HWNDPARENT
482 ${IfNot} $R0 == 0
483 GetDlgItem $R1 $R0 ${item_id}
484 EnableWindow $R1 ${enable}
485 ${EndIf}
486 !macroend
488 !macro SkipToNextPage
489 GetDlgItem $R0 $HWNDPARENT 1
490 System::Call "User32::PostMessage(i $HWNDPARENT, i ${WM_COMMAND}, i 1, i $R0)"
491 !macroend
494 ;--------------------------------
495 ;Install Files
496 ;--------------------------------
498 Section "-PreInit"
499 SetShellVarContext all
500 SetOutPath "$INSTDIR"
501 SectionEnd
503 Section "-Clean Up Old Cruft"
504 !insertmacro PrintProgress "$(X264_LANG_STATUS_CLEANUP)"
505 !insertmacro CleanUpFiles ""
506 SectionEnd
508 Section "!Install Files"
509 !insertmacro PrintProgress "$(X264_LANG_STATUS_INSTFILES)"
511 DeleteOldBinary:
512 !insertmacro GetExecutableName $R0
513 ClearErrors
514 Delete "$INSTDIR\$R0"
516 ${If} ${Errors}
517 MessageBox MB_TOPMOST|MB_ICONSTOP|MB_RETRYCANCEL 'Could not delete old "$R0" file. Is program still running?' IDRETRY DeleteOldBinary
518 Abort "Could not delete old binary!"
519 ${EndIf}
521 File /a `/oname=$R0` `${X264_SOURCE_PATH}\x264_launcher.exe`
523 File /a `${X264_SOURCE_PATH}\*.dll`
524 File /a `${X264_SOURCE_PATH}\*.txt`
525 File /a `${X264_SOURCE_PATH}\*.html`
527 SetOutPath "$INSTDIR\imageformats"
528 File /a /r `${X264_SOURCE_PATH}\imageformats\*.*`
530 SetOutPath "$INSTDIR\toolset"
531 File /a /r `${X264_SOURCE_PATH}\toolset\*.*`
533 SetOutPath "$INSTDIR\sources"
534 File /a /r `${X264_SOURCE_PATH}\sources\*.*`
535 SectionEnd
537 Section "-Write Uinstaller"
538 !insertmacro PrintProgress "$(X264_LANG_STATUS_MAKEUNINST)"
539 WriteUninstaller "$INSTDIR\Uninstall.exe"
540 SectionEnd
542 Section "-Create Shortcuts"
543 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
544 !insertmacro PrintProgress "$(X264_LANG_STATUS_SHORTCUTS)"
545 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
547 SetShellVarContext current
549 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
550 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
551 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
553 SetShellVarContext all
555 Delete "$SMPROGRAMS\$StartMenuFolder\*.lnk"
556 Delete "$SMPROGRAMS\$StartMenuFolder\*.pif"
557 Delete "$SMPROGRAMS\$StartMenuFolder\*.url"
559 !insertmacro GetExecutableName $R0
561 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk" "$INSTDIR\$R0" "" "$INSTDIR\$R0" 0
562 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(X264_LANG_LINK_LICENSE).lnk" "$INSTDIR\LICENSE.html"
563 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(X264_LANG_LINK_MANUAL).lnk" "$INSTDIR\README.html"
564 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(X264_LANG_LINK_CHANGELOG).lnk" "$INSTDIR\HISTORY.txt"
565 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$(X264_LANG_LINK_UNINSTALL).lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0
567 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\MuldeR's Homepage.url" "${MyWebSite}"
568 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Doom9's Forum.url" "http://forum.doom9.org/"
569 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\x264.com.url" "http://x264.com/"
570 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\x265.com.url" "http://x265.org/"
571 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\Avisynth Wiki.url" "http://avisynth.nl/"
572 !insertmacro CreateWebLink "$SMPROGRAMS\$StartMenuFolder\VapourSynth.com.url" "http://www.vapoursynth.com/"
574 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk"
575 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "Simple x264 Launcher.lnk" ${StdUtils.Const.ShellVerb.PinToTaskbar}
576 DetailPrint 'Pin: "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk" -> $R1'
577 ${EndIf}
578 !insertmacro MUI_STARTMENU_WRITE_END
579 SectionEnd
581 Section "-Update Registry"
582 !insertmacro PrintProgress "$(X264_LANG_STATUS_REGISTRY)"
584 !insertmacro GetExecutableName $R0
585 WriteRegStr HKLM "${MyRegPath}" "InstallLocation" "$INSTDIR"
586 WriteRegStr HKLM "${MyRegPath}" "ExecutableName" "$R0"
587 WriteRegStr HKLM "${MyRegPath}" "DisplayIcon" "$INSTDIR\$R0,0"
588 WriteRegStr HKLM "${MyRegPath}" "UninstallString" '"$INSTDIR\Uninstall.exe"'
589 WriteRegStr HKLM "${MyRegPath}" "DisplayName" "Simple x264 Launcher v2"
590 WriteRegStr HKLM "${MyRegPath}" "Publisher" "LoRd_MuldeR <mulder2@gmx.de>"
591 WriteRegStr HKLM "${MyRegPath}" "DisplayVersion" "Build #${X264_BUILD} (${X264_DATE})"
592 WriteRegStr HKLM "${MyRegPath}" "URLInfoAbout" "${MyWebSite}"
593 WriteRegStr HKLM "${MyRegPath}" "URLUpdateInfo" "${MyWebSite}"
595 DeleteRegKey HKCU "${AppPaths}\x264_launcher.exe"
596 WriteRegStr HKLM "${AppPaths}\x264_launcher.exe" "" "$INSTDIR\$R0"
597 WriteRegStr HKLM "${AppPaths}\x264_launcher.exe" "Path" "$INSTDIR"
598 SectionEnd
600 Section "-Finished"
601 !insertmacro PrintProgress "$(MUI_TEXT_FINISH_TITLE)."
602 ${IfThen} ${UnattendedMode} ${|} SetAutoClose true ${|}
603 SectionEnd
606 ;--------------------------------
607 ;Uninstaller
608 ;--------------------------------
610 Section "Uninstall"
611 SetOutPath "$EXEDIR"
612 !insertmacro PrintProgress "$(X264_LANG_STATUS_UNINSTALL)"
614 ; --------------
615 ; Startmenu
616 ; --------------
618 !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
619 ${IfNot} "$StartMenuFolder" == ""
620 SetShellVarContext current
621 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk"
622 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "Simple x264 Launcher.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
623 DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk" -> $R1'
624 ${EndIf}
625 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
626 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
627 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
628 RMDir "$SMPROGRAMS\$StartMenuFolder"
629 ${EndIf}
631 SetShellVarContext all
632 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk"
633 ${StdUtils.InvokeShellVerb} $R1 "$SMPROGRAMS\$StartMenuFolder" "Simple x264 Launcher.lnk" ${StdUtils.Const.ShellVerb.UnpinFromTaskbar}
634 DetailPrint 'Unpin: "$SMPROGRAMS\$StartMenuFolder\Simple x264 Launcher.lnk" -> $R1'
635 ${EndIf}
636 ${If} ${FileExists} "$SMPROGRAMS\$StartMenuFolder\*.*"
637 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.lnk"
638 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuFolder\*.url"
639 RMDir "$SMPROGRAMS\$StartMenuFolder"
640 ${EndIf}
641 ${EndIf}
643 ; --------------
644 ; Files
645 ; --------------
647 ReadRegStr $R0 HKLM "${MyRegPath}" "ExecutableName"
648 ${IfThen} "$R0" == "" ${|} StrCpy $R0 "x264_launcher.exe" ${|}
650 Delete /REBOOTOK "$INSTDIR\$R0"
651 !insertmacro CleanUpFiles /REBOOTOK
652 RMDir "$INSTDIR"
654 ; --------------
655 ; Registry
656 ; --------------
658 DeleteRegKey HKLM "${MyRegPath}"
659 DeleteRegKey HKCU "${MyRegPath}"
661 DeleteRegKey HKLM "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
662 DeleteRegKey HKCU "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{54dcbccb-c905-46dc-b6e6-48563d0e9e55}"
664 DeleteRegKey HKLM "${AppPaths}\x264_launcher.exe"
665 DeleteRegKey HKCU "${AppPaths}\x264_launcher.exe"
667 MessageBox MB_YESNO|MB_TOPMOST "$(X264_LANG_UNINST_PERSONAL)" IDNO +3
668 Delete "$LOCALAPPDATA\LoRd_MuldeR\Simple x264 Launcher\*.ini"
669 RMDir "$LOCALAPPDATA\LoRd_MuldeR\Simple x264 Launcher"
671 !insertmacro PrintProgress "$(MUI_UNTEXT_FINISH_TITLE)."
672 SectionEnd
675 ;--------------------------------
676 ;Check For Update Mode
677 ;--------------------------------
679 Function SkipIfUnattended
680 ${IfThen} ${UnattendedMode} ${|} Abort ${|}
681 FunctionEnd
683 Function CheckForUpdate
684 ${If} "$INSTDIR" == ""
685 ${OrIf} "$INSTDIR" == "$EXEDIR"
686 ${OrIfNot} ${FileExists} "$INSTDIR\x264_launcher.exe"
687 StrCpy $UpdateNotificationShown FALSE
688 !insertmacro SetControlEnabled 1019 1
689 !insertmacro SetControlEnabled 1001 1
690 Return
691 ${Else}
692 !insertmacro SetControlEnabled 1019 0
693 !insertmacro SetControlEnabled 1001 0
694 ${If} "$UpdateNotificationShown" != TRUE
695 StrCpy $UpdateNotificationShown TRUE
696 MessageBox MB_ICONINFORMATION|MB_TOPMOST "$(X264_LANG_UNINST_UPDATE_MODE)"
697 !insertmacro SkipToNextPage
698 ${EndIf}
699 ${EndIf}
700 FunctionEnd
702 Function un.CheckForcedUninstall
703 ${IfThen} ${ForcedMode} ${|} Abort ${|}
704 FunctionEnd
707 ;--------------------------------
708 ;Locked List
709 ;--------------------------------
711 !macro _LockedListShow uinst
712 !insertmacro MUI_HEADER_TEXT "$(X264_LANG_LOCKEDLIST_HEADER)" "$(X264_LANG_LOCKEDLIST_TEXT)"
713 ${If} ${UnattendedMode}
714 !insertmacro DisableBackButton $R0
715 ${EndIf}
716 ${If} ${RunningX64}
717 InitPluginsDir
718 File /oname=$PLUGINSDIR\LockedList64.dll `${NSISDIR}\Plugins\LockedList64.dll`
719 ${EndIf}
720 !insertmacro GetExecutableName $R0
721 LockedList::AddModule "\$R0"
722 ${If} "$R0" != "x264_launcher.exe"
723 LockedList::AddModule "\x264_launcher.exe"
724 ${EndIf}
725 LockedList::AddModule "\Uninstall.exe"
726 !if ${uinst} < 1
727 LockedList::AddModule "\Au_.exe"
728 !endif
729 #LockedList::AddFolder "$INSTDIR"
730 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)"
731 Pop $R0
732 !macroend
734 Function LockedListShow
735 !insertmacro _LockedListShow 0
736 FunctionEnd
738 Function un.LockedListShow
739 !insertmacro _LockedListShow 1
740 FunctionEnd
743 ;--------------------------------
744 ;Install Success
745 ;--------------------------------
747 Function RunAppFunction
748 !insertmacro DisableNextButton $R0
749 !insertmacro GetExecutableName $R0
750 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR" "explore" ""
751 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\$R0" "open" "--first-run"
752 FunctionEnd
754 Function ShowReadmeFunction
755 !insertmacro DisableNextButton $R0
756 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\README.html" "open" ""
757 FunctionEnd
759 Function .onInstSuccess
760 ${If} ${UnattendedMode}
761 !insertmacro GetExecutableName $R0
762 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR" "explore" ""
763 ${StdUtils.ExecShellAsUser} $R1 "$INSTDIR\$R0" "open" "--first-run"
764 ${EndIf}
765 FunctionEnd