-
-
Notifications
You must be signed in to change notification settings - Fork 61
/
FastFlix.nsi
156 lines (110 loc) · 5.25 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
; FastFlix.nsi
;
!include "MUI2.nsh"
!include LogicLib.nsh
!include "TextFunc.nsh"
!include "FileFunc.nsh"
;--------------------------------
!define PRODUCT_NAME "FastFlix"
!define PRODUCT_AUTHOR "Chris Griffith"
!define PRODUCT_COPYRIGHT "(c) Chris Griffith 2021-2024"
VIProductVersion "${PRODUCT_VERSION}"
VIFileVersion "${PRODUCT_VERSION}"
; -------------------------------------------------------------------- Installer exe properties
VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
VIAddVersionKey "CompanyName" "${PRODUCT_AUTHOR}"
VIAddVersionKey "LegalTrademarks" "${PRODUCT_COPYRIGHT}"
VIAddVersionKey "LegalCopyright" "${PRODUCT_COPYRIGHT}"
VIAddVersionKey "FileVersion" "${PRODUCT_VERSION}"
VIAddVersionKey "FileDescription" "${PRODUCT_NAME} installer"
VIAddVersionKey "InternalName" "${PRODUCT_NAME}"
; The name of the installer
Name "${PRODUCT_NAME} ${VERSION}"
; 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\${PRODUCT_NAME}
; Registry key to check for directory (so if you install again, it will overwrite the old one automatically)
InstallDirRegKey HKLM "Software\${PRODUCT_NAME}" "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 "$(LSTR05)"
!insertmacro MUI_PAGE_FINISH
;Languages
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Italian"
LangString LSTR01 1033 "Before proceeding with the installation of ${PRODUCT_NAME} you must uninstall the currently installed version.$\r$\n$\r$\nPlease ensure that ${PRODUCT_NAME} is not currently running!"
LangString LSTR02 1033 "FastFlix (required)"
LangString LSTR03 1033 "Start Menu Shortcuts"
LangString LSTR04 1033 "Uninstall"
LangString LSTR05 1033 "Thank you for installing ${PRODUCT_NAME}!"
LangString LSTR01 1040 "Prima di procedere all'installazione di ${PRODUCT_NAME} è necessario disinstallare la versione attualmente installata.$\r$\n$\r$\nAssicurati che ${PRODUCT_NAME} non sia attualmente in esecuzione!"
LangString LSTR02 1040 "FastFlix (richiesto)"
LangString LSTR03 1040 "Collegamenti menu Start"
LangString LSTR04 1040 "Disinstalla"
LangString LSTR05 1040 "Grazie per aver installato ${PRODUCT_NAME}!"
;--------------------------------
Function .onInit
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\FastFlix" "UninstallString"
${If} $0 != ""
Messagebox MB_OK|MB_ICONINFORMATION "$(LSTR01)"
ExecWait '$0 _?=$INSTDIR'
${EndIf}
FunctionEnd
; The stuff to install
Section "$(LSTR02)"
SectionIn RO
; Set output path to the installation directory.
SetOutPath $INSTDIR
Delete "$INSTDIR\uninstall.exe"
; Put file there
File /r "dist\${PRODUCT_NAME}\*"
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\${PRODUCT_NAME} "Install_Dir" "$INSTDIR"
WriteRegStr HKLM SOFTWARE\${PRODUCT_NAME} "UninstallString" '"$INSTDIR\uninstall.exe"'
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayName" "${PRODUCT_NAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayVersion" "${VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "Publisher" "${PRODUCT_AUTHOR}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayIcon" "$INSTDIR\FastFlix.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "NoRepair" 1
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0 #< conv to DWORD
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "EstimatedSize" "$0"
WriteUninstaller "$INSTDIR\uninstall.exe"
SectionEnd
; Optional section (can be disabled by the user)
Section "$(LSTR03)"
CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
CreateShortcut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\FastFlix.exe"
CreateShortcut "$SMPROGRAMS\${PRODUCT_NAME}\$(LSTR04) ${PRODUCT_NAME}.lnk" "$INSTDIR\uninstall.exe"
SectionEnd
; Uninstaller
Section "Uninstall"
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
DeleteRegKey HKLM SOFTWARE\${PRODUCT_NAME}
; Remove files
Delete $INSTDIR\*
; Remove shortcuts, if any
Delete "$SMPROGRAMS\${PRODUCT_NAME}\*.lnk"
; Remove directories
RMDir "$SMPROGRAMS\${PRODUCT_NAME}"
RMDir /r "$INSTDIR"
RMDir "$INSTDIR"
Delete "$INSTDIR\uninstall.exe"
SectionEnd