-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.nsi
371 lines (266 loc) · 8.4 KB
/
install.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
!include MUI.nsh
!include LogicLib.nsh
!include nsDialogs.nsh
!include WinMessages.nsh
!include FileFunc.nsh
!include WinVer.nsh
Name "Practice"
OutFile ".\build\Practice_${version}_${from}.exe"
SetCompressor /SOLID lzma
Icon ".\app\icons\icon-32.ico"
UninstallIcon ".\app\icons\icon-32.ico"
!define MUI_ICON ".\app\icons\icon-32.ico"
!define MUI_UNICON ".\app\icons\icon-32.ico"
# !define MUI_FINISHPAGE_RUN "$INSTDIR\Practice.exe"
InstallDir "$PROGRAMFILES\Practice"
Page custom welcome
Page instfiles
Page custom finish
# !define MUI_PAGE_INSTFILES install
UninstPage uninstConfirm
UninstPage instfiles
RequestExecutionLevel admin
XPStyle on
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE SimpChinese
VIProductVersion "0.0.2.0"
VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "ProductName" "Practice"
VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "Comments" "Comments"
VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "CompanyName" "CompanyName"
VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "LegalTrademarks" "LegalTrademarks"
VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "LegalCopyright" "LegalCopyright"
VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "FileDescription" "Practice"
VIAddVersionKey /LANG=${LANG_SIMPCHINESE} "FileVersion" "0.0.2.0"
Var HEADLINE_FONT
Function .onInit
InitPluginsDir
File /oname=$PLUGINSDIR\page1.bmp ".\app\icons\page1.bmp"
File /oname=$PLUGINSDIR\page2.bmp ".\app\icons\page2.bmp"
FunctionEnd
Function HideControls
LockWindow on
GetDlgItem $0 $HWNDPARENT 1
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 2
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 3
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1028
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1256
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1035
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1037
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1038
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1039
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1045
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1034
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1035
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1036
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1037
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1038
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1039
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1256
ShowWindow $0 ${SW_HIDE}
GetDlgItem $0 $HWNDPARENT 1028
ShowWindow $0 ${SW_HIDE}
LockWindow off
FunctionEnd
Function ShowControls
LockWindow on
GetDlgItem $0 $HWNDPARENT 1
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 2
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 3
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1028
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1256
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1035
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1037
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1038
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1039
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1045
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1034
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1035
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1036
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1037
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1038
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1039
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1256
ShowWindow $0 ${SW_NORMAL}
GetDlgItem $0 $HWNDPARENT 1028
ShowWindow $0 ${SW_NORMAL}
LockWindow off
FunctionEnd
Var Dialog
Var Image
Var ImageHandle
Var InstallBtn
Var DirBtn
Var DirLabel
Function welcome
# System::Call 'user32::SetWindowPos(i$hwndparent,i,i,i,i 590,i 415,i 0x16)' ; Resize outer dialog
nsDialogs::Create 1044
Pop $Dialog
System::Call 'user32::MoveWindow(i$Dialog,i0,i0,i 500,i 336,i0)'
SetCtlColors $Dialog "" 0xffffff
${NSD_CreateLabel} 20 -30 270 12 ""
Pop $DirLabel
SetCtlColors $DirLabel "" 0xffffff
ShowWindow $DirLabel ${SW_HIDE}
${NSD_CreateButton} -100 -30 80 20 "Next"
Pop $InstallBtn
${NSD_OnClick} $InstallBtn onClickNext
${NSD_CreateButton} -200 -30 80 20 "Custom Dir"
Pop $DirBtn
${NSD_OnClick} $DirBtn showDirDialog
${NSD_CreateBitmap} 0 0 100% 100% ""
Pop $IMAGE
${NSD_SetImage} $Image $PLUGINSDIR\page1.bmp $ImageHandle
SetCtlColors $Image "" 0xffffff
Call HideControls
nsDialogs::Show
Call ShowControls
FunctionEnd
Function showDirDialog
nsDialogs::SelectFolderDialog "Custom Dir" ""
Pop $0
${IF} $0 == error
${ELSE}
StrCpy $INSTDIR $0
${NSD_SetText} $DirLabel $INSTDIR
ShowWindow $DirLabel ${SW_NORMAL}
SetOutPath $INSTDIR
${EndIf}
FunctionEnd
Function RelGotoPage
IntCmp $R9 0 0 Move Move
StrCmp $R9 "X" 0 Move
StrCpy $R9 "120"
Move:
SendMessage $HWNDPARENT "0x408" "$R9" ""
FunctionEnd
Function onClickNext
StrCpy $R9 1
Call RelGotoPage
Abort
FunctionEnd
Var CompleteBtn
Var Progress
Function finish
# System::Call 'user32::SetWindowPos(i$hwndparent,i,i,i,i 590,i 415,i 0x16)' ; Resize outer dialog
nsDialogs::Create 1044
Pop $Dialog
# System::Call 'user32::MoveWindow(i$Dialog,i0,i0,i 590,i 415,i0)'
System::Call 'user32::MoveWindow(i$Dialog,i0,i0,i 500,i 336,i0)'
SetCtlColors $Dialog "" 0xffffff
${NSD_CreateButton} -100 -30 80 20 "Complete"
Pop $CompleteBtn
# ${NSD_OnClick} $CompleteBtn startInstall
${NSD_OnClick} $CompleteBtn onClickComplete
# ${NSD_CreateProgressBar} 20 355 400 20 ""
# Pop $Progress
# ${NSD_CreateTimer} OnTimer 200
${NSD_CreateBitmap} 0 0 100% 100% ""
Pop $IMAGE
${NSD_SetImage} $Image $PLUGINSDIR\page2.bmp $ImageHandle
SetCtlColors $Image "" 0xffffff
Call HideControls
nsDialogs::Show
FunctionEnd
Function OnTimer
SendMessage $Progress ${PBM_GETPOS} 0 0 $1
${If} $1 >= 100
${NSD_KillTimer} OnTimer
MessageBox MB_OK "Timer 3 killed"
${Else}
SendMessage $Progress ${PBM_DELTAPOS} 2 0
${EndIf}
FunctionEnd
Function onClickComplete
# StrCpy $R9 1
# Call RelGotoPage
# Abort
# Quit
# MessageBox MB_OK "Open exe"
Exec '"$INSTDIR\Practice.exe"'
SendMessage $HwndParent ${WM_CLOSE} 0 0
Abort
FunctionEnd
Section
DetailPrint "¿ªÊ¼°²×°¡£¡£¡£"
DetailPrint $INSTDIR
SetOutPath $INSTDIR
# File "README.md"
File /r "E:\Workspace\MeMe-RIA\build\MeMeLive\win32\*.*"
# File /r "E:\Workspace\MeMe-RIA\build\MeMeLive\win32\Practice.exe"
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\Practice "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Practice" "DisplayName" "Practice"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Practice" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Practice" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Practice" "NoRepair" 1
CreateShortCut "$DESKTOP\Practice.lnk" "$INSTDIR\Practice.exe"
WriteUninstaller "$INSTDIR\UninstallMeMeLive.exe"
CreateDirectory "$STARTMENU\Practice"
CreateShortcut "$STARTMENU\Practice\UninstallPractice.lnk" "$INSTDIR\UninstallMeMeLive.exe"
CreateShortcut "$STARTMENU\Practice\Practice.lnk" "$INSTDIR\Practice.exe"
# CreateDirectory "$STARTMENU\User Pinned\TaskBar"
# CreateShortcut "$QUICKLAUNCH\Practice.lnk" "$INSTDIR\Practice.exe"
# CreateShortcut "$QUICKLAUNCH\User Pinned\TaskBar\Practice.lnk" "$INSTDIR\Practice.exe"
# pin the icon to taskbar
${IF} ${IsWin10}
${ELSE}
ExecShell "taskbarpin" "$STARTMENU\Practice\Practice.lnk"
${EndIf}
# goto next pagte
StrCpy $R9 1
Call RelGotoPage
Abort
SectionEnd
Section "Uninstall"
DetailPrint "Start Uninstall"
DetailPrint "$INSTDIR"
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Practice"
DeleteRegKey HKLM SOFTWARE\Practice
# unpin stskbar link
ExecShell "taskbarunpin" "$STARTMENU\Practice\Practice.lnk"
; Remove shortcuts, if any
Delete "$DESKTOP\Practice.lnk"
Delete "$STARTMENU\Practice\*.*"
RMDir "$STARTMENU\Practice"
; Remove files and uninstaller
Delete "$INSTDIR\*.*"
; Remove directories used
RMDir /r "$INSTDIR\locales"
RMDir /r "$INSTDIR\PepperFlash"
RMDir /r "$INSTDIR\pnacl"
RMDir "$INSTDIR"
SectionEnd