-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstaller.nsi
162 lines (124 loc) · 4.86 KB
/
Installer.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
157
158
159
160
161
162
!include "MUI2.nsh"
;--------------------------------
; General
;Name and file
!define COMPANY "Casterlabs"
!define NAME "Casterlabs Caffeinated"
Name "${NAME}"
OutFile "dist/Casterlabs-Caffeinated-Setup.exe"
Unicode True
;Default installation folder
InstallDir "$PROGRAMFILES64\${NAME}"
;Request application privileges for Windows Vista
RequestExecutionLevel admin
;--------------------------------
; Interface Settings
!define MUI_ICON "icon.ico"
!define MUI_HEADERIMAGE
;!define MUI_WELCOMEFINISHPAGE_BITMAP "assets\welcome.bmp"
;!define MUI_HEADERIMAGE_BITMAP "assets\head.bmp"
!define MUI_ABORTWARNING
!define MUI_WELCOMEPAGE_TITLE "${NAME} Setup"
;--------------------------------
;Pages
; Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "APP_EULA.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ModifyUnWelcome
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
; Var deleteUserData ; You could just store the HWND in $1 etc if you don't want this extra variable
;--------------------------------
; Section - Installer
Section "Remove Previous Version" RemovePrev
SectionIn RO
RMDir /r "$INSTDIR"
SectionEnd
Section "App" AppInst
SectionIn RO
SetOutPath "$INSTDIR"
File /r "dist\build\windows-x86_64\*.*"
WriteUninstaller "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY} ${NAME}" \
"DisplayName" "${NAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY} ${NAME}" \
"UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY} ${NAME}" \
"QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /S"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY} ${NAME}" \
"EstimatedSize" 610000
SectionEnd
Section "Desktop Shortcut" DeskShort
IfSilent +2 ; Don't create Desktop shortcut when silent.
CreateShortCut "$DESKTOP\${NAME}.lnk" "$INSTDIR\Casterlabs-Caffeinated-Updater.exe"
SectionEnd
Section "Start Menu Shortcut" StartShort
IfSilent +4 ; Don't create StartMenu shortcut when silent.
CreateDirectory "$SMPROGRAMS\${COMPANY}"
CreateShortCut "$SMPROGRAMS\${COMPANY}\${NAME}.lnk" "$INSTDIR\Casterlabs-Caffeinated-Updater.exe"
CreateShortCut "$SMPROGRAMS\${COMPANY}\Uninstall ${NAME}.lnk" "$INSTDIR\Uninstall.exe"
SectionEnd
;--------------------------------
; Section - Uninstaller
Function un.ModifyUnWelcome
;${NSD_CreateCheckbox} 120u -20u 50% 20u $(DESC_DeleteUserData)
;Pop $deleteUserData
;SetCtlColors $deleteUserData "" ${MUI_BGCOLOR}
;${NSD_Check} $deleteUserData ; Unchecked by default
FunctionEnd
Function un.RMDirUP
!define RMDirUP '!insertmacro RMDirUPCall'
!macro RMDirUPCall _PATH
push '${_PATH}'
Call un.RMDirUP
!macroend
; $0 - current folder
ClearErrors
Exch $0
;DetailPrint "ASDF - $0\.."
RMDir "$0\.."
IfErrors Skip
${RMDirUP} "$0\.."
Skip:
Pop $0
FunctionEnd
Section "Uninstall"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY} ${NAME}"
;${NSD_GetState} $deleteUserData $0
;${If} $0 <> 0
; RMDir /r "$APPDATA\casterlabs-caffeinated\preferences" ; Preferences
; ${RMDirUP} "$APPDATA\casterlabs-caffeinated\preferences"
; RMDir /r "$APPDATA\casterlabs-caffeinated\plugins" ; Plugins
; ${RMDirUP} "$APPDATA\casterlabs-caffeinated\plugins"
;${EndIf}
RMDir /r "$APPDATA\casterlabs-caffeinated\app" ; App
RMDir /r "$APPDATA\casterlabs-caffeinated\ipc" ; IPC
RMDir /r "$APPDATA\casterlabs-caffeinated\api" ; API
RMDir /r "$APPDATA\casterlabs-caffeinated\logs" ; Logs
Delete "$INSTDIR\Uninstall.exe"
RMDir /r "$INSTDIR" ; Updater
${RMDirUP} "$INSTDIR"
Delete "$DESKTOP\${NAME}.lnk"
Delete "$SMPROGRAMS\${COMPANY}\${NAME}.lnk"
SectionEnd
;--------------------------------
; Languages
!insertmacro MUI_LANGUAGE "English"
;Language strings
LangString DESC_RemovePrev ${LANG_ENGLISH} "Remove the previous version (keeping user data intact)."
LangString DESC_AppInst ${LANG_ENGLISH} "Install the app."
LangString DESC_DeskShort ${LANG_ENGLISH} "Create Shortcut on Desktop."
LangString DESC_StartShort ${LANG_ENGLISH} "Create Start Menu folder."
LangString DESC_DeleteUserData ${LANG_ENGLISH} "Delete user preferences and plugins"
;Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${RemovePrev} $(DESC_RemovePrev)
!insertmacro MUI_DESCRIPTION_TEXT ${AppInst} $(DESC_AppInst)
!insertmacro MUI_DESCRIPTION_TEXT ${DeskShort} $(DESC_DeskShort)
!insertmacro MUI_DESCRIPTION_TEXT ${StartShort} $(DESC_StartShort)
!insertmacro MUI_FUNCTION_DESCRIPTION_END