forked from cdgriffith/FastFlix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFastFlix.nsi
112 lines (77 loc) · 2.96 KB
/
FastFlix.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
; FastFlix.nsi
;
!include "MUI2.nsh"
!include LogicLib.nsh
;--------------------------------
; The name of the installer
Name "FastFlix"
; The file to write
OutFile "FastFlix_installer.exe"
; Request application privileges for Windows Vista and higher
RequestExecutionLevel admin
; Build Unicode installer
Unicode True
SetCompressor lzma
; The default installation directory
InstallDir $PROGRAMFILES64\FastFlix
; Registry key to check for directory (so if you install again, it will overwrite the old one automatically)
InstallDirRegKey HKLM "Software\FastFlix" "Install_Dir"
;--------------------------------
; Pages
!insertmacro MUI_PAGE_LICENSE "docs\build-licenses.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!define MUI_FINISHPAGE_TEXT "Thank you for installing FastFlix!"
!insertmacro MUI_PAGE_FINISH
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
Function .onInit
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FastFlix" "UninstallString"
${If} $0 != ""
Messagebox MB_OK|MB_ICONINFORMATION "You will now be prompted to first uninstall the previous version of FastFlix"
ExecWait '$0 _?=$INSTDIR'
${EndIf}
FunctionEnd
; The stuff to install
Section "FastFlix (required)"
SectionIn RO
; Set output path to the installation directory.
SetOutPath $INSTDIR
Delete "$INSTDIR\uninstall.exe"
; Put file there
File /r "dist\FastFlix\*"
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\FastFlix "Install_Dir" "$INSTDIR"
WriteRegStr HKLM SOFTWARE\FastFlix "UninstallString" '"$INSTDIR\uninstall.exe"'
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FastFlix" "DisplayName" "FastFlix"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FastFlix" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FastFlix" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FastFlix" "NoRepair" 1
WriteUninstaller "$INSTDIR\uninstall.exe"
SectionEnd
; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"
CreateDirectory "$SMPROGRAMS\FastFlix"
CreateShortcut "$SMPROGRAMS\FastFlix\FastFlix.lnk" "$INSTDIR\FastFlix.exe"
CreateShortcut "$SMPROGRAMS\FastFlix\Uninstall FastFlix.lnk" "$INSTDIR\uninstall.exe"
SectionEnd
; Uninstaller
Section "Uninstall"
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FastFlix"
DeleteRegKey HKLM SOFTWARE\FastFlix
; Remove files
Delete $INSTDIR\*
; Remove shortcuts, if any
Delete "$SMPROGRAMS\FastFlix\*.lnk"
; Remove directories
RMDir "$SMPROGRAMS\FastFlix"
RMDir /r "$INSTDIR"
RMDir "$INSTDIR"
Delete "$INSTDIR\uninstall.exe"
SectionEnd