-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlazyadb.nsi
146 lines (106 loc) · 3.76 KB
/
lazyadb.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
;--------------------------------
;Include Modern UI
!include "MUI2.nsh"
;--------------------------------
;General
; Set version
!define AppVersion "1.1"
;Name and file
Name "LazyADB"
OutFile "build\LazyADB_v${AppVersion}.exe"
ShowInstDetails Show
Unicode True
!define MUI_ICON "assets\icon.ico"
!define MUI_UNICON "assets\icon.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "assets\logo.bmp"
!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
!define MUI_HEADERIMAGE_RIGHT
;Default installation folder
InstallDir "$LOCALAPPDATA\LazyADB"
;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\LazyADB" ""
RequestExecutionLevel user
BrandingText "LazyADB Installer"
VIProductVersion "${AppVersion}.0.0"
VIAddVersionKey "ProductName" "LazyADB"
VIAddVersionKey "FileDescription" "With LazyADB, it will always download the latest adb from Google, just click next, next, next,... and enjoy."
VIAddVersionKey "FileVersion" "${AppVersion}"
SpaceTexts none
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
;--------------------------------
;Pages
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
LangString nsisunz_text ${LANG_ENGLISH} "Extract: %f (%c -> %b) [%p]"
;--------------------------------
;Installer Sections
Section "Installer"
InitPluginsDir
SetOutpath "$INSTDIR"
nsProcessW::_FindProcess "adb.exe"
Pop $R0
${If} $R0 == 0
MessageBox MB_OK|MB_ICONEXCLAMATION "adb is running. Please close it first" /SD IDOK
DetailPrint "Aborted"
Abort
${EndIf}
NSISdl::download "https://dl.google.com/android/repository/platform-tools-latest-windows.zip" "$INSTDIR\platform-tools-latest-windows.zip" /END
Pop $0
${If} $0 == "success"
${Else}
MessageBox mb_iconstop "Download failed: $0"
DetailPrint "Aborted"
Abort
${EndIf}
nsisunz::UnzipToLog "$INSTDIR\platform-tools-latest-windows.zip" "$INSTDIR"
; Always check result on stack
Pop $0
${If} $0 == "success"
${Else}
MessageBox mb_iconstop "Extract failed: $0"
Delete "platform-tools-latest-windows.zip"
DetailPrint "Aborted"
Abort
${EndIf}
Delete "platform-tools-latest-windows.zip"
;--------------
; ADD PATH
EnVar::SetHKCU
EnVar::AddValueEx "path" "$INSTDIR\platform-tools"
;Store installation folder
WriteRegStr HKCU "Software\LazyADB" "" $INSTDIR
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstaller.exe"
;Add uninstall information to Add/Remove Programs
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\LazyADB" "DisplayName" "LazyADB"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\LazyADB" "UninstallString" "$\"$INSTDIR\Uninstaller.exe$\""
SectionEnd
;--------------------------------
;Uninstaller Section
Section "Uninstall"
nsProcessW::_FindProcess "adb.exe"
Pop $R0
${If} $R0 == 0
MessageBox MB_OK|MB_ICONEXCLAMATION "adb is running. Please close it first" /SD IDOK
DetailPrint "Aborted"
Abort
${EndIf}
;--------------
; REMOVE PATH
; Check if the path entry already exists and write result to $0
EnVar::SetHKCU
EnVar::DeleteValue "path" "$INSTDIR\platform-tools"
Delete "$INSTDIR\*.*"
Delete "$INSTDIR\Uninstaller.exe"
RMDir /r "$INSTDIR"
DeleteRegKey HKCU "Software\LazyADB"
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\LazyADB"
SectionEnd