-
Notifications
You must be signed in to change notification settings - Fork 0
/
cartographer-gui.nsi
337 lines (270 loc) · 10.7 KB
/
cartographer-gui.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
; Original script generated by the HM NIS Edit Script Wizard.
; now copied from agent installer and modified
; $Id: cartographer-gui.nsi 151 2011-03-31 14:33:54Z rdk $
; mods by rdk
;
; Copyright 2011, Krupczak.org, LLC
;
; This program is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of the
; License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful, but
; WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
; USA
; -----------------------------------------------------------------------
; Variables and defines
; am I already installed? Is Java installed?
Var alreadyInstalled
Var javaAlreadyInstalled
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Cartographer GUI"
!define PRODUCT_VERSION "0.33"
!define PRODUCT_PUBLISHER "Krupczak.org, LLC"
!define PRODUCT_WEB_SITE "http://www.krupczak.org/cartographer"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\Cartographer.jar"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
; MUI 1.67 compatible ------
; Use MUI2 instead of MUI 1.x
!include "MUI2.nsh"
!include "LogicLib.nsh"
!include "servicelib.nsh"
!include "x64.nsh"
!include "WinVer.nsh"
; request application privileges for Vista+
RequestExecutionLevel admin
BrandingText "© 2011 Krupczak.org, LLC. Installer made with NSIS"
; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "cartographer-installer.ico"
!define MUI_UNICON "cartographer-installer.ico"
VIProductVersion "0.33.0.0"
ViAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "Cartographer GUI"
ViAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "Installer produced with NSIS and HM NIS Editor"
ViAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "Krupczak.org, LLC"
ViAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "Copyright 2011, Krupczak.org, LLC"
ViAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "0.33.0.0"
ViAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Cartographer GUI Windows Installer"
; -----------------------------------------------------------------------
; install pages
; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "license.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; write registry and use a page for it
Page custom pageWriteRegistryStart
; Finish page
!insertmacro MUI_PAGE_FINISH
; -----------------------------------------------------------------------
; Uninstaller pages
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
; Language files
!insertmacro MUI_LANGUAGE "English"
; MUI end ------
; -----------------------------------------------------------------------
; functions and page-functions
; prevent multiple instances of installer and check for other
; parameters at start of the installer
; if x64, set Registry view to 64
; check if already installed; if installed and we wish to continue
; go ahead and try to stop the service anyway
; dont sleep as the service stop will wait for service to finish
Function .onInit
${If} ${RunningX64}
SetRegView 64
${EndIf}
${If} ${AtMostWin2000}
MessageBox MB_OK|MB_ICONEXCLAMATION "This installer cannot be run on anything prior to Windows XP"
Abort
${EndIf}
call isJavaInstalled
StrCmp $javaAlreadyInstalled "true" carryOn 0
MessageBox MB_YESNO "Java is not installed; do you wish to continue anyway?" IDYES carryOnYes IDNO 0
Abort
carryOnYes:
carryOn:
call isCartographerGUIInstalled
StrCmp $alreadyInstalled "false" continueInstall 0
MessageBox MB_YESNO "Cartographer GUI is already installed. Do you wish to continue?" IDYES yesContinue IDNO 0
Abort
yesContinue:
continueInstall:
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "cartographerInstallerMutex") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
Abort
FunctionEnd
; -------------
; dummy page to write registry entries
;
Function pageWriteRegistryStart
call writeRegistryEntries
!insertmacro MUI_HEADER_TEXT "Writing Registry Entries" ""
nsDialogs::Create 1018
${NSD_CreateLabel} 0 5u 100% 20u "Writing Registry Entries"
nsDialogs::Show
FunctionEnd
; -------------
; on win2k08, these entries do not appear to get written despite the
; fact that we ask for admin permissions
; its not win2k08, but 64-bit or 32-bit that is at work here
; use SetRegView to specify 32 or 64-bit
Function writeRegistryEntries
WriteRegStr HKLM "Software\Krupczak.org" "Description" "The Krupczak Organization"
WriteRegStr HKLM "Software\Krupczak.org" "URL" "http://www.krupczak.org"
WriteRegStr HKLM "Software\Krupczak.org\Cartographer GUI" "URL" "${PRODUCT_WEB_SITE}"
WriteRegStr HKLM "Software\Krupczak.org\Cartographer GUI" "InstallDir" "$INSTDIR"
WriteRegStr HKLM "Software\Krupczak.org\Cartographer GUI" "HowInstalled" "GUI"
WriteRegStr HKLM "Software\Krupczak.org\Cartographer GUI" "Version" "${PRODUCT_VERSION}"
FunctionEnd
; -------------
Function removeRegistryEntries
DeleteRegKey HKLM "Software\Krupczak.org\Cartographer GUI"
FunctionEnd
Function un.removeRegistryEntries
DeleteRegKey HKLM "Software\Krupczak.org\Cartographer GUI"
FunctionEnd
; -------------
Function closeProgram
Exch $1
Push $0
loop:
FindWindow $0 $1
IntCmp $0 0 done
# SendMessage $0 ${WM_DESTROY} 0 0
SendMessage $0 ${WM_CLOSE} 0 0
Sleep 100
Goto loop
done:
Pop $0
Pop $1
FunctionEnd
Function un.closeProgram
Exch $1
Push $0
loop:
FindWindow $0 $1
IntCmp $0 0 done
# SendMessage $0 ${WM_DESTROY} 0 0
SendMessage $0 ${WM_CLOSE} 0 0
Sleep 100
Goto loop
done:
Pop $0
Pop $1
FunctionEnd
; -------------
; is Cartographer GUI already installed?
; check if file Cartographer.jar exists
Function isCartographerGUIInstalled
!undef UN
!define UN ""
StrCpy $alreadyInstalled "false"
ifFileExists $INSTDIR\Cartographer.jar 0 notExists
StrCpy $alreadyInstalled "true"
notExists:
FunctionEnd
; -------------
; is Java JRE installed?
; check registry entries
Function isJavaInstalled
!undef UN
!define UN ""
Push $R0
StrCpy $javaAlreadyInstalled "false"
ReadRegStr $R0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
StrCmp $R0 "" JRENotFound
StrCpy $javaAlreadyInstalled "true"
JRENotFound:
FunctionEnd
; -----------------------------------------------------------------------
; sections
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "cartographer-gui.exe"
InstallDir "$PROGRAMFILES\cartographer-gui"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite try
File "lib\Cartographer.jar"
File "lib\Xmp.jar"
File "lib\jgraph.jar"
File "lib\jgraphlayout.jar"
File "lib\license.txt"
SectionEnd
; ------------------------------------------------
Section -AdditionalIcons
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
CreateShortCut "$SMPROGRAMS\Cartographer-GUI\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
CreateShortCut "$SMPROGRAMS\Cartographer-GUI\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd
; ------------------------------------------------
Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\Cartographer.jar"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\xmpd-win32.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd
; ------------------------------------------------
; this function invoked after successful install
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd
; this function invoked before install starts
; prevent multiple instance of uninstaller
; if x64, set Registry view to 64
Function un.onInit
${If} ${RunningX64}
SetRegView 64
${EndIf}
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "cartographerInstallerMutex") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
Abort
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
Abort
FunctionEnd
; ------------------------------------------------
Section Uninstall
DetailPrint "Removing registry entries"
call un.removeRegistryEntries
Delete "$INSTDIR\${PRODUCT_NAME}.url"
Delete "$INSTDIR\Cartographer.jar"
Delete "$INSTDIR\Xmp.jar"
Delete "$INSTDIR\jgraph.jar"
Delete "$INSTDIR\jgraphlayout.jar"
Delete "$INSTDIR\license.txt"
; finally, remove the install dir
RmDir "$INSTDIR"
Delete "$SMPROGRAMS\Cartographer-GUI\Uninstall.lnk"
Delete "$SMPROGRAMS\Cartographer-GUI\Website.lnk"
RMDir "$SMPROGRAMS\Cartographer-GUI"
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd
; -----------------------------------------------------------------------