106
129
LangString TEXT_IO_TITLE ${LANG_ENGLISH} "GSmartControl"
110
; --------------- START INSTALLATION
115
!insertmacro MUI_LANGDLL_DISPLAY
117
Push 2 ;F ;22 = number of languages, F = change font
120
LangDLL::LangDialog "Installer Language" "Please select a language."
123
StrCmp $LANGUAGE "cancel" 0 +2
126
; detect previous installation
127
ReadRegStr $R0 HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
128
StrCmp $R0 "" no_prev
130
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
131
"${PRODUCT_NAME} is already installed. $\n$\nClick 'OK' to remove the \
132
previous version or 'Cancel' to continue anyway." \
135
goto no_prev ; if cancel was pressed, continue as if no old installation.
140
ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
142
IfErrors cannot_uninst_product
144
;You can either use Delete /REBOOTOK in the uninstaller or add some code
145
;here to remove the uninstaller. Use a registry key to check
146
;whether the user has chosen to uninstall. If you are using an uninstaller
147
;components page, make sure all sections are uninstalled.
148
cannot_uninst_product:
150
no_prev: ; no old installation found, all ok
155
; detect GTK installation (any of available versions)
156
ReadRegStr $R0 HKLM "SOFTWARE\GTK\2.0" "DllPath"
162
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
163
"GTK2-Runtime is not installed. This product needs it to function properly.$\n\
164
Please install GTK2-Runtime from http://gtk-win.sf.net/ first.$\n$\n\
165
Click 'Cancel' to abort the installation \
166
or 'OK' to continue anyway." \
132
var install_option_removeold ; uninstall the old version first (if present): yes (default), no.
180
136
; ----------------- INSTALLATION TYPES
182
138
; InstType "Recommended"
191
Section "Main" SecMain
193
SetOutPath "$INSTDIR"
195
SetOverwrite Off ; don't overwrite the config file
196
; File "gsmartcontrol.conf"
199
File gsmartcontrol.exe
200
File gsmartcontrol.ico
208
; set a special path for this exe, as GTK may not be in a global path.
209
ReadRegStr $R3 HKLM "SOFTWARE\GTK\2.0" "DllPath"
210
WriteRegStr HKLM "${REGISTRY_APP_PATHS}\gsmartcontrol.exe" "Path" "$R3"
213
CreateShortCut "$SMPROGRAMS\GSmartControl.lnk" "$INSTDIR\gsmartcontrol.exe" "" "$INSTDIR\gsmartcontrol.ico" 0
145
Section "!GSmartControl" SecMain
147
SetShellVarContext all ; use all user variables as opposed to current user
148
SetOutPath "$INSTDIR"
150
SetOverwrite Off ; don't overwrite the config file
151
; File "gsmartcontrol.conf"
154
File gsmartcontrol.exe
155
File gsmartcontrol.exe.manifest
156
File gsmartcontrol.ico
161
File update-smart-drivedb.exe
163
; Include the "doc" directory completely, excluding the file we're not using (e.g. the -nogtk file in gtk installer).
165
File /r /x distribution.txt doc
167
File /r /x distribution-nogtk.txt doc
170
; Add Shortcuts (this inherits the exe's run permissions)
171
CreateShortCut "$SMPROGRAMS\GSmartControl.lnk" "$INSTDIR\gsmartcontrol.exe" "" \
172
"$INSTDIR\gsmartcontrol.ico" "" SW_SHOWNORMAL "" "GSmartControl - Hard disk drive health inspection tool"
180
; The SecGtkPrivate and SecGtkPublic sections are mutually exclusive.
182
Section "GTK+ (for this program only)" SecGtkPrivate
184
SetShellVarContext all ; use all user variables as opposed to current user
185
AddSize 12200 ; ~ size of unpacked gtk
186
SetOutPath "$INSTDIR"
187
File "${GTK_INSTALLER_EXE}"
188
; TODO: in the future, when we have translations for this program,
189
; make the GTK+ translations installation dependent on their installation status.
190
ExecWait '"${GTK_INSTALLER_EXE}" /sideeffects=no /dllpath=root /translations=no /compatdlls=no /S /D=$INSTDIR'
191
Delete "$INSTDIR\${GTK_INSTALLER_EXE}"
194
; disabled by default
195
Section /o "GTK+ (shared installation)" SecGtkPublic
197
SetShellVarContext all ; use all user variables as opposed to current user
198
AddSize 12200 ; ~ size of unpacked gtk
199
SetOutPath "$INSTDIR"
200
File "${GTK_INSTALLER_EXE}"
201
ExecWait '"${GTK_INSTALLER_EXE}"'
202
Delete "$INSTDIR\${GTK_INSTALLER_EXE}"
209
var gtk_mode ; "public", "private" or "none"
210
var gtk_tmp ; temporary variable
214
; Executed on installation start
216
SetShellVarContext all ; use all user variables as opposed to current user
218
${GetOptions} "$CMDLINE" "/removeold=" $install_option_removeold
220
Call PreventMultipleInstances
222
Call DetectPrevInstallation
224
; ask for gtk only if it's a non-gtk installer.
230
StrCpy $gtk_mode "private" ; default
237
function .onselchange
240
; Remember which gtk section was selected.
241
; Deselect the other section.
243
; If it was private, we check if public is checked and uncheck private.
245
StrCmp $gtk_mode "private" check_public ; old selection
246
StrCmp $gtk_mode "public" check_private ; old selection
250
SectionGetFlags ${SecGtkPublic} $gtk_tmp ; see if it's checked
251
IntOp $gtk_tmp $gtk_tmp & ${SF_SELECTED}
252
IntCmp $gtk_tmp ${SF_SELECTED} "" check_exit check_exit
253
SectionGetFlags ${SecGtkPrivate} $gtk_tmp ; unselect the other one
254
IntOp $gtk_tmp $gtk_tmp & ${SECTION_OFF}
255
SectionSetFlags ${SecGtkPrivate} $gtk_tmp
259
SectionGetFlags ${SecGtkPrivate} $gtk_tmp ; see if it's checked
260
IntOp $gtk_tmp $gtk_tmp & ${SF_SELECTED}
261
IntCmp $gtk_tmp ${SF_SELECTED} "" check_exit check_exit
262
SectionGetFlags ${SecGtkPublic} $gtk_tmp ; unselect the other one
263
IntOp $gtk_tmp $gtk_tmp & ${SECTION_OFF}
264
SectionSetFlags ${SecGtkPublic} $gtk_tmp
269
; store the current mode
270
StrCpy $gtk_mode "none"
272
SectionGetFlags ${SecGtkPrivate} $gtk_tmp
273
IntOp $gtk_tmp $gtk_tmp & ${SF_SELECTED}
274
IntCmp $gtk_tmp ${SF_SELECTED} "" mode_end_private mode_end_private
275
StrCpy $gtk_mode "private"
278
SectionGetFlags ${SecGtkPublic} $gtk_tmp
279
IntOp $gtk_tmp $gtk_tmp & ${SF_SELECTED}
280
IntCmp $gtk_tmp ${SF_SELECTED} "" mode_end_public mode_end_public
281
StrCpy $gtk_mode "public"
284
; MessageBox MB_ICONINFORMATION|MB_OK "gtk_mode: $gtk_mode" /SD IDOK
291
Function on_components_page_leave
292
StrCmp $gtk_mode "none" "" noabort
301
; Section descriptions
302
!ifndef NO_GTK ; this page is shown only when using gtk
303
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
304
!insertmacro MUI_DESCRIPTION_TEXT ${SecMain} "GSmartControl - hard disk drive health inspection tool"
305
!insertmacro MUI_DESCRIPTION_TEXT ${SecGtkPrivate} "GTK+ libraries, needed by GSmartControl. \
306
This will install a private version of GTK+, usable only by GSmartControl."
307
!insertmacro MUI_DESCRIPTION_TEXT ${SecGtkPublic} "GTK+ libraries, needed by GSmartControl. \
308
This will install a system-wide version of GTK+, shareable with other programs."
309
!insertmacro MUI_FUNCTION_DESCRIPTION_END
219
313
; ------------------ POST INSTALL
226
WriteRegStr HKLM "SOFTWARE\${PRODUCT_NAME}" "InstallationDirectory" "$INSTDIR"
227
WriteRegStr HKLM "SOFTWARE\${PRODUCT_NAME}" "Vendor" "Alexander Shaduri"
229
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayName" "${PRODUCT_NAME}"
230
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\gsmartcontrol_uninst.exe"
232
; We don't need this, MUI takes care for us
233
WriteRegStr HKCU "Software\${PRODUCT_NAME}" "Installer Language" $LANGUAGE
236
; CreateDirectory "$SMPROGRAMS\GSmartControl"
237
; CreateShortCut "$SMPROGRAMS\GSmartControl\Uninstall GSmartControl.lnk" "$INSTDIR\gsmartcontrol_uninst.exe" "" ""
240
; write out uninstaller
241
WriteUninstaller "$INSTDIR\gsmartcontrol_uninst.exe"
319
SetShellVarContext all ; use all user variables as opposed to current user
321
; Don't set any paths for this exe if it has a private GTK+ installation.
323
StrCmp $gtk_mode "private" skip_exe_PATH
325
; set a special path for this exe, as GTK may not be in a global path.
326
ReadRegStr $gtk_dll_abs_path HKLM "SOFTWARE\GTK\2.0" "DllPath"
327
WriteRegStr HKLM "${REGISTRY_APP_PATHS}\gsmartcontrol.exe" "Path" "$gtk_dll_abs_path"
333
WriteRegStr HKLM "SOFTWARE\${PRODUCT_NAME}" "GtkInstalledMode" "$gtk_mode"
336
WriteRegStr HKLM "SOFTWARE\${PRODUCT_NAME}" "InstallationDirectory" "$INSTDIR"
337
WriteRegStr HKLM "SOFTWARE\${PRODUCT_NAME}" "Vendor" "${PRODUCT_PUBLISHER}"
339
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayName" "${PRODUCT_NAME}"
340
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\gsmartcontrol_uninst.exe"
341
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "InstallLocation" "$INSTDIR"
342
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
343
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\gsmartcontrol.ico"
344
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
345
WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
346
WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoModify" 1
347
WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoRepair" 1
349
; We don't need this, MUI takes care for us
350
; WriteRegStr HKCU "Software\${PRODUCT_NAME}" "Installer Language" $sUAGE
352
; write out uninstaller
353
WriteUninstaller "$INSTDIR\gsmartcontrol_uninst.exe"
356
;CreateDirectory "$SMPROGRAMS\GSmartControl"
357
;CreateShortCut "$SMPROGRAMS\GSmartControl\Uninstall GSmartControl.lnk" "$INSTDIR\gsmartcontrol_uninst.exe" "" ""
243
359
SectionEnd ; post
253
369
Function un.onUninstSuccess
255
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
371
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." /SD IDOK
261
377
Section Uninstall
265
; add delete commands to delete whatever files/registry keys/etc you installed here.
266
Delete "$INSTDIR\gsmartcontrol_uninst.exe"
268
DeleteRegKey HKLM "SOFTWARE\${PRODUCT_NAME}"
269
DeleteRegKey HKLM "${PRODUCT_UNINST_KEY}"
271
Delete "$INSTDIR\gsmartcontrol.exe"
272
Delete "$INSTDIR\gsmartcontrol.ico"
273
Delete "$INSTDIR\icon_*.png"
274
; Delete "$INSTDIR\*.dll"
275
Delete "$INSTDIR\smartctl-nc.exe"
276
Delete "$INSTDIR\smartctl.exe"
278
RMDir /r "$INSTDIR\doc"
280
RMDir "$INSTDIR" ; only if empty
282
DeleteRegKey HKLM "${REGISTRY_APP_PATHS}\gsmartcontrol.exe"
284
Delete "$SMPROGRAMS\GSmartControl.lnk"
285
; Delete "$SMPROGRAMS\GSmartControl\Uninstall GSmartControl.lnk"
378
SetShellVarContext all ; use all user variables as opposed to current user
382
ReadRegStr $gtk_mode HKLM "SOFTWARE\${PRODUCT_NAME}" "GtkInstalledMode"
383
StrCmp $gtk_mode "private" "" skip_gtk_remove
384
; remove private GTK+, specify the same custom options are during installation
385
ExecWait "$INSTDIR\gtk2_runtime_uninst.exe /remove_config=yes /sideeffects=no /dllpath=root /translations=no /compatdlls=no /S"
387
; Delete "$INSTDIR\gtk2_runtime_uninst.exe" ; If using _? flag, it won't get deleted automatically, do it manually.
391
; add delete commands to delete whatever files/registry keys/etc you installed here.
392
Delete "$INSTDIR\gsmartcontrol_uninst.exe"
394
DeleteRegKey HKLM "SOFTWARE\${PRODUCT_NAME}"
395
DeleteRegKey HKLM "${PRODUCT_UNINST_KEY}"
397
Delete "$INSTDIR\gsmartcontrol.exe"
398
Delete "$INSTDIR\gsmartcontrol.exe.manifest"
399
Delete "$INSTDIR\gsmartcontrol.ico"
400
Delete "$INSTDIR\icon_*.png"
401
; Delete "$INSTDIR\*.dll"
402
Delete "$INSTDIR\smartctl-nc.exe"
403
Delete "$INSTDIR\smartctl.exe"
404
Delete "$INSTDIR\update-smart-drivedb.exe"
406
RMDir /r "$INSTDIR\doc"
408
; clean up generated stuff
409
Delete "$INSTDIR\*stdout.txt"
410
Delete "$INSTDIR\*stderr.txt"
412
RMDir "$INSTDIR" ; only if empty
415
StrCmp $gtk_mode "private" skip_exe_PATH_remove
417
DeleteRegKey HKLM "${REGISTRY_APP_PATHS}\gsmartcontrol.exe"
419
skip_exe_PATH_remove:
422
Delete "$SMPROGRAMS\GSmartControl.lnk"
423
;Delete "$SMPROGRAMS\GSmartControl\Uninstall GSmartControl.lnk"
288
425
SectionEnd ; end of uninstall section
b'\\ No newline at end of file'
429
; --------------- Helpers
431
; Detect previous installation
432
Function DetectPrevInstallation
433
; if /removeold=no option is given, don't check anything.
434
StrCmp $install_option_removeold "no" old_detect_done
436
SetShellVarContext all ; use all user variables as opposed to current user
439
; detect previous installation
440
ReadRegStr $R0 HKLM "${PRODUCT_UNINST_KEY}" "UninstallString"
441
StrCmp $R0 "" old_detect_done
443
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
444
"${PRODUCT_NAME} is already installed. $\n$\nClick `OK` to remove the \
445
previous version or `Cancel` to continue anyway." \
446
/SD IDOK IDOK old_uninst
450
; Run the old uninstaller
453
IfSilent old_silent_uninst old_nosilent_uninst
457
goto old_uninst_continue
460
ExecWait '$R0 /S _?=$INSTDIR'
464
IfErrors old_no_remove_uninstaller
466
; You can either use Delete /REBOOTOK in the uninstaller or add some code
467
; here to remove to remove the uninstaller. Use a registry key to check
468
; whether the user has chosen to uninstall. If you are using an uninstaller
469
; components page, make sure all sections are uninstalled.
470
old_no_remove_uninstaller:
472
old_detect_done: ; old installation not found, all ok
479
; detect GTK installation (any of available versions)
481
SetShellVarContext all ; use all user variables as opposed to current user
484
ReadRegStr $R0 HKLM "SOFTWARE\GTK\2.0" "DllPath"
485
StrCmp $R0 "" no_gtk have_gtk
488
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
489
"GTK2-Runtime is not installed. This product needs it to function properly.$\n\
490
Please install GTK2-Runtime from http://gtk-win.sf.net/ first.$\n$\n\
491
Click 'Cancel' to abort the installation \
492
or 'OK' to continue anyway." \
493
/SD IDOK IDOK have_gtk
494
;Abort ; Abort has different meaning from onpage callbacks, so use Quit
508
; Prevent running multiple instances of the installer
509
Function PreventMultipleInstances
511
System::Call 'kernel32::CreateMutexA(i 0, i 0, t ${PRODUCT_NAME}) ?e'
514
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running." /SD IDOK