]> git.street.me.uk Git - andy/viking.git/blame - win32/installer/viking-installer.nsi
Merge pull request #14 from apre/master
[andy/viking.git] / win32 / installer / viking-installer.nsi
CommitLineData
773eb66a
MA
1; Installer script for win32 Viking
2; Based on Win32 Pidgin installer by Herman Bloggs <hermanator12002@yahoo.com>
3; and Daniel Atallah <daniel_atallah@yahoo.com>
4; Heavily modified for Viking by Mathieu Albinet <mathieu_a@users.sourceforge.net>
5
6;--------------------------------
7;Global Variables
8Var name
9
10;--------------------------------
11;Configuration
e70384e0 12;Needs to be 4 numbers: W.X.Y.Z
51d6704c 13!define VIKING_VERSION "1.6.1.0"
773eb66a
MA
14
15;The name var is set in .onInit
16Name $name
17
0edf62b8
RN
18;Allow overiding location of binary components for the install
19!ifndef BINARIES
20 !define BINARIES ".\bin"
21!endif
22
773eb66a
MA
23OutFile "viking-${VIKING_VERSION}.exe"
24
0edf62b8
RN
25;NB Using /SOLID method on a mingw32 setup seems to generate an exe that fails the CRC check
26;So now don't set the compressor here - it can be set by the calling command/script if necessary.
27;SetCompressor /SOLID bzip2
773eb66a
MA
28ShowInstDetails show
29ShowUninstDetails show
30SetDateSave on
31
32; $name and $INSTDIR are set in .onInit function..
33
34!include "MUI.nsh"
35!include "Sections.nsh"
36!include "WinVer.nsh"
37!include "LogicLib.nsh"
b0678771 38!include "x64.nsh"
93950f79
MA
39;; http://nsis.sourceforge.net/File_Association
40!include "FileAssociation.nsh"
773eb66a
MA
41
42!include "FileFunc.nsh"
43!insertmacro GetParameters
44!insertmacro GetOptions
45!insertmacro GetParent
46
47!include "WordFunc.nsh"
48
49;--------------------------------
50;Defines
51
52!define VIKING_NSIS_INCLUDE_PATH "."
53
54; Remove these and the stuff that uses them at some point
55!define VIKING_REG_KEY "SOFTWARE\viking"
56!define VIKING_UNINSTALL_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\viking"
57
58!define HKLM_APP_PATHS_KEY "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\viking.exe"
59!define VIKING_UNINST_EXE "viking-uninst.exe"
60
773eb66a
MA
61;--------------------------------
62;Version resource
63VIProductVersion "${VIKING_VERSION}"
64VIAddVersionKey "ProductName" "Viking"
65VIAddVersionKey "FileVersion" "${VIKING_VERSION}"
66VIAddVersionKey "ProductVersion" "${VIKING_VERSION}"
67VIAddVersionKey "LegalCopyright" ""
68VIAddVersionKey "FileDescription" "Viking Installer"
69
70;--------------------------------
71;Modern UI Configuration
72
73 !define MUI_ICON ".\pixmaps\viking_icon.ico"
74 !define MUI_UNICON ".\pixmaps\viking_icon.ico"
75; !define MUI_WELCOMEFINISHPAGE_BITMAP ".\pixmaps\viking-intro.bmp"
76; !define MUI_HEADERIMAGE
77; !define MUI_HEADERIMAGE_BITMAP ".\pixmaps\viking-header.bmp"
78
79 ; Alter License section
80 !define MUI_LICENSEPAGE_BUTTON $(VIKING_LICENSE_BUTTON)
81 !define MUI_LICENSEPAGE_TEXT_BOTTOM $(VIKING_LICENSE_BOTTOM_TEXT)
82
83 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
84 !define MUI_LANGDLL_REGISTRY_KEY ${VIKING_REG_KEY}
85 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
86
87 !define MUI_COMPONENTSPAGE_SMALLDESC
88 !define MUI_ABORTWARNING
89
90 ;Finish Page config
91 !define MUI_FINISHPAGE_NOAUTOCLOSE
92 !define MUI_FINISHPAGE_RUN "$INSTDIR\viking.exe"
93 !define MUI_FINISHPAGE_RUN_NOTCHECKED
94 !define MUI_FINISHPAGE_LINK $(VIKING_FINISH_VISIT_WEB_SITE)
95 !define MUI_FINISHPAGE_LINK_LOCATION "http://viking.sourceforge.net"
96
97;--------------------------------
98;Pages
99
100 !insertmacro MUI_PAGE_WELCOME
0edf62b8 101 !insertmacro MUI_PAGE_LICENSE "${BINARIES}\COPYING_GPL.txt"
773eb66a
MA
102 !insertmacro MUI_PAGE_COMPONENTS
103
104 ; Viking install dir page
105 !insertmacro MUI_PAGE_DIRECTORY
106
107 !insertmacro MUI_PAGE_INSTFILES
108 !insertmacro MUI_PAGE_FINISH
109
110 !insertmacro MUI_UNPAGE_WELCOME
111 !insertmacro MUI_UNPAGE_CONFIRM
112 !insertmacro MUI_UNPAGE_INSTFILES
113 !insertmacro MUI_UNPAGE_FINISH
114
115;--------------------------------
116;Languages
117
118 ;; English goes first because its the default. The rest are
119 ;; in alphabetical order (at least the strings actually displayed
120 ;; will be).
121
122 !insertmacro MUI_LANGUAGE "English"
123 !insertmacro MUI_LANGUAGE "French"
25d341c5 124 !insertmacro MUI_LANGUAGE "Spanish"
773eb66a
MA
125
126;--------------------------------
127;Translations
128
129 !define VIKING_DEFAULT_LANGFILE "${VIKING_NSIS_INCLUDE_PATH}\translations\english.nsh"
130
131 !include "${VIKING_NSIS_INCLUDE_PATH}\langmacros.nsh"
132
133 !insertmacro VIKING_MACRO_INCLUDE_LANGFILE "ENGLISH" "${VIKING_NSIS_INCLUDE_PATH}\translations\english.nsh"
134 !insertmacro VIKING_MACRO_INCLUDE_LANGFILE "FRENCH" "${VIKING_NSIS_INCLUDE_PATH}\translations\french.nsh"
c34f39b7 135 !insertmacro VIKING_MACRO_INCLUDE_LANGFILE "SPANISH" "${VIKING_NSIS_INCLUDE_PATH}\translations\spanish.nsh"
773eb66a
MA
136
137;--------------------------------
138;Reserve Files
139 ; Only need this if using bzip2 compression
140
141 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
142 !insertmacro MUI_RESERVEFILE_LANGDLL
143 ReserveFile "${NSISDIR}\Plugins\UserInfo.dll"
144
145
146;;;;;;;;;;;;;;;;;;;;;;;;;;;;
147;; Start Install Sections ;;
148;;;;;;;;;;;;;;;;;;;;;;;;;;;;
149
0edf62b8 150LicenseData "${BINARIES}\COPYING_GPL.txt"
64e07c22
RN
151LicenseForceSelection checkbox
152
773eb66a
MA
153;--------------------------------
154;Uninstall any old version of Viking
155
156Section -SecUninstallOldViking
157 ; Check install rights..
158 Call CheckUserInstallRights
159 Pop $R0
160
161 ;First try to uninstall Viking
162 StrCpy $R4 ${VIKING_REG_KEY}
163 StrCpy $R5 ${VIKING_UNINSTALL_KEY}
164 StrCpy $R6 ${VIKING_UNINST_EXE}
165 StrCpy $R7 "Viking"
166
167 ;Determine user install rights
168 StrCmp $R0 "HKLM" compare_hklm
169 StrCmp $R0 "HKCU" compare_hkcu done
170
171 compare_hkcu:
172 ReadRegStr $R1 HKCU $R4 ""
173 ReadRegStr $R2 HKCU $R4 "Version"
174 ReadRegStr $R3 HKCU "$R5" "UninstallString"
175 Goto try_uninstall
176
177 compare_hklm:
178 ReadRegStr $R1 HKLM $R4 ""
179 ReadRegStr $R2 HKLM $R4 "Version"
180 ReadRegStr $R3 HKLM "$R5" "UninstallString"
181
182 ; If a previous version exists, remove it
183 try_uninstall:
184 StrCmp $R1 "" done
185 StrCmp $R2 "" uninstall_problem
186 ; Check if we have uninstall string..
187 IfFileExists $R3 0 uninstall_problem
188 ; Have uninstall string, go ahead and uninstall.
189 SetOverwrite on
190 ; Need to copy uninstaller outside of the install dir
191 ClearErrors
192 CopyFiles /SILENT $R3 "$TEMP\$R6"
193 SetOverwrite off
194 IfErrors uninstall_problem
195 ; Ready to uninstall..
196 ClearErrors
197 ExecWait '"$TEMP\$R6" /S _?=$R1'
198 IfErrors exec_error
199 Delete "$TEMP\$R6"
200 Goto done
201
202 exec_error:
203 Delete "$TEMP\$R6"
204 Goto uninstall_problem
205
206 uninstall_problem:
207 ; We can't uninstall. Either the user must manually uninstall or we ignore and reinstall over it.
208 MessageBox MB_OKCANCEL $(VIKING_PROMPT_CONTINUE_WITHOUT_UNINSTALL) /SD IDOK IDOK done
209 Quit
210 done:
211SectionEnd
212
68648226 213
773eb66a
MA
214;--------------------------------
215;Viking Install Section
216
217Section $(VIKING_SECTION_TITLE) SecViking
218 SectionIn 1 RO
219
220 ; Check install rights..
221 Call CheckUserInstallRights
222 Pop $R0
223 StrCmp $R0 "NONE" viking_none
224 StrCmp $R0 "HKLM" viking_hklm viking_hkcu
225
226 ;Install rights for Local Machine
227 viking_hklm:
228 WriteRegStr HKLM "${HKLM_APP_PATHS_KEY}" "" "$INSTDIR\viking.exe"
229 WriteRegStr HKLM "${HKLM_APP_PATHS_KEY}" "Path" "$R1\bin"
773eb66a
MA
230 ; Sets scope of the desktop and Start Menu entries for all users.
231 SetShellVarContext "all"
232 Goto viking_install_files
233
234 ;Install rights for Current User only
235 viking_hkcu:
773eb66a
MA
236 Goto viking_install_files
237
238 ;No install rights!
239 viking_none:
240
241 viking_install_files:
242 SetOutPath "$INSTDIR"
243 SetOverwrite on
244
68648226
RN
245 ; Common settings
246 WriteRegStr SHCTX ${VIKING_REG_KEY} "" "$INSTDIR"
247 WriteRegStr SHCTX ${VIKING_REG_KEY} "Version" "${VIKING_VERSION}"
b0678771
RN
248 ${If} ${RunningX64}
249 WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "DisplayName" "Viking (x86)"
250 ${Else}
251 WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "DisplayName" "Viking (x64)"
252 ${EndIf}
68648226
RN
253 WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "DisplayVersion" "${VIKING_VERSION}"
254 WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "DisplayIcon" "$INSTDIR\viking_icon.ico"
255 WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "HelpLink" "http://sourceforge.net/p/viking/wikiallura"
256 WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "URLInfoAbout" "http://sourceforge.net/projects/viking/"
257 WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "Publisher" "The Viking developer community"
258 WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "Comments" "$(VIKING_UNINSTALL_COMMENTS)"
259 WriteRegDWORD SHCTX "${VIKING_UNINSTALL_KEY}" "NoModify" 1
260 WriteRegDWORD SHCTX "${VIKING_UNINSTALL_KEY}" "NoRepair" 1
261 WriteRegStr SHCTX "${VIKING_UNINSTALL_KEY}" "UninstallString" "$INSTDIR\${VIKING_UNINST_EXE}"
262
263 ; Copy only specific items as now some components (e.g. GPSBabel) are optional.
264 ; This is mostly to get a more accurate install size value (especially as saved into the registry)
0edf62b8
RN
265 File ${BINARIES}\viking*
266 File ${BINARIES}\g*.exe
267 File ${BINARIES}\*.dll
268 File ${BINARIES}\*.txt
269 File ${BINARIES}\magic.mgc
270 File /r ${BINARIES}\data
271 File /r ${BINARIES}\locale
68648226
RN
272
273 ; Estimate install size based on files in $INSTDIR
274 ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
275 IntFmt $0 "0x%08X" $0
276 WriteRegDWORD SHCTX "${VIKING_UNINSTALL_KEY}" "EstimatedSize" "$0"
773eb66a
MA
277
278 ; If we don't have install rights we're done
279 StrCmp $R0 "NONE" done
280 SetOverwrite off
281
282 ; write out uninstaller
283 SetOverwrite on
284 WriteUninstaller "$INSTDIR\${VIKING_UNINST_EXE}"
285 SetOverwrite off
286
c6311c82
RN
287 ; Always associate Viking file type
288 ${registerExtension} "$INSTDIR\viking.exe" ".vik" "Viking File"
773eb66a
MA
289 done:
290SectionEnd ; end of default Viking section
291
292;--------------------------------
293;Shortcuts
294
295SectionGroup /e $(VIKING_SHORTCUTS_SECTION_TITLE) SecShortcuts
296 ;Desktop shortcuts
297 Section /o $(VIKING_DESKTOP_SHORTCUT_SECTION_TITLE) SecDesktopShortcut
298 SetOverwrite on
299 CreateShortCut "$DESKTOP\Viking.lnk" "$INSTDIR\viking.exe"
300 SetOverwrite off
301 SectionEnd
302 ;Start menu shortcuts
303 Section $(VIKING_STARTMENU_SHORTCUT_SECTION_TITLE) SecStartMenuShortcut
304 SetOverwrite on
305 CreateDirectory "$SMPROGRAMS\Viking"
306 CreateShortCut "$SMPROGRAMS\Viking\Viking.lnk" "$INSTDIR\viking.exe"
307 CreateShortCut "$SMPROGRAMS\Viking\User Manual.lnk" "$INSTDIR\viking.pdf"
308 CreateShortCut "$SMPROGRAMS\Viking\Uninstall.lnk" "$INSTDIR\viking-uninst.exe"
309 SetOverwrite off
310 SectionEnd
311SectionGroupEnd
312
93950f79
MA
313;--------------------------------
314;File association
773eb66a 315
93950f79 316Section $(VIKING_FILE_ASSOCIATION_SECTION_TITLE) SecFileAssociation
c6311c82 317 ${registerExtension} "$INSTDIR\viking.exe" ".gpx" "GPX File"
93950f79 318SectionEnd
773eb66a 319
f570ee2b
RN
320;--------------------------------
321; GPSBabel Install Section
322;
323Section $(VIKING_GPSBABEL_SECTION_TITLE) SecGPSBabel
0edf62b8 324 File "${BINARIES}\Optional\GPSBabel-1.5.2-Setup.exe"
c1b746db
RN
325 ExecWait '"$INSTDIR\GPSBabel-1.5.2-Setup.exe" /SILENT'
326 Delete "$INSTDIR\GPSBabel-1.5.2-Setup.exe"
f570ee2b 327SectionEnd
773eb66a
MA
328
329;--------------------------------
330;Uninstaller Section
331
332
333Section Uninstall
334 Call un.CheckUserInstallRights
335 Pop $R0
336 StrCmp $R0 "NONE" no_rights
337 StrCmp $R0 "HKCU" try_hkcu try_hklm
338
339 try_hkcu:
340 ReadRegStr $R0 HKCU ${VIKING_REG_KEY} ""
341 StrCmp $R0 $INSTDIR 0 cant_uninstall
342 ; HKCU install path matches our INSTDIR so uninstall
343 DeleteRegKey HKCU ${VIKING_REG_KEY}
344 DeleteRegKey HKCU "${VIKING_UNINSTALL_KEY}"
345 Goto cont_uninstall
346
347 try_hklm:
348 ReadRegStr $R0 HKLM ${VIKING_REG_KEY} ""
349 StrCmp $R0 $INSTDIR 0 try_hkcu
350 ; HKLM install path matches our INSTDIR so uninstall
351 DeleteRegKey HKLM ${VIKING_REG_KEY}
352 DeleteRegKey HKLM "${VIKING_UNINSTALL_KEY}"
353 DeleteRegKey HKLM "${HKLM_APP_PATHS_KEY}"
354 ; Sets start menu and desktop scope to all users..
355 SetShellVarContext "all"
356
357 cont_uninstall:
358
68648226
RN
359 ; http://nsis.sourceforge.net/Docs/Chapter4.html
360 ; Don't use:
361 ;RMDir /r "$INSTDIR"
362 ; Warning: is not safe. Can delete entire Program Files directory!
363
364 ; TODO try this method instead:
365 ; http://nsis.sourceforge.net/Uninstall_only_installed_files
366
367 ; Specific remove files
368 ; Thus alsos leaves any files the user has saved (particularly .vik or .gpx) into the Viking directory
369 Delete "$INSTDIR\viking-cache.py"
370 Delete "$INSTDIR\viking.pdf"
371 Delete "$INSTDIR\viking_icon.ico"
372 Delete "$INSTDIR\*.exe"
373 Delete "$INSTDIR\*.dll"
374 Delete "$INSTDIR\*.txt"
375 Delete "$INSTDIR\magic.mgc"
376 Delete "$INSTDIR\data\*txt"
377 Delete "$INSTDIR\data\*xml"
378 RMDir "$INSTDIR\data"
68648226 379 RMDir /r "$INSTDIR\locale"
68648226 380 RMDir "$INSTDIR"
773eb66a
MA
381
382 ; Shortcuts..
383 Delete "$DESKTOP\Viking.lnk"
384
93950f79
MA
385 ; File association
386 ${unregisterExtension} ".vik" "Viking File"
c6311c82 387 ${unregisterExtension} ".gpx" "GPX File"
93950f79 388
773eb66a
MA
389 Goto done
390
391 cant_uninstall:
392 MessageBox MB_OK $(un.VIKING_UNINSTALL_ERROR_1) /SD IDOK
393 Quit
394
395 no_rights:
396 MessageBox MB_OK $(un.VIKING_UNINSTALL_ERROR_2) /SD IDOK
397 Quit
398
399 done:
400SectionEnd ; end of uninstall section
401
402;--------------------------------
403;Descriptions
404!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
405
406 !insertmacro MUI_DESCRIPTION_TEXT ${SecViking} \
407 $(VIKING_SECTION_DESCRIPTION)
408 !insertmacro MUI_DESCRIPTION_TEXT ${SecShortcuts} \
409 $(VIKING_SHORTCUTS_SECTION_DESCRIPTION)
410 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktopShortcut} \
411 $(VIKING_DESKTOP_SHORTCUT_DESC)
412 !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenuShortcut} \
413 $(VIKING_STARTMENU_SHORTCUT_DESC)
93950f79
MA
414 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssociation} \
415 $(VIKING_FILE_ASSOCIATION_DESC)
f570ee2b
RN
416 !insertmacro MUI_DESCRIPTION_TEXT ${SecGPSBabel} \
417 $(VIKING_INSTALL_GPSBABEL_DESC)
773eb66a
MA
418
419!insertmacro MUI_FUNCTION_DESCRIPTION_END
420
421;--------------------------------
422;Functions
423
424;Macro to determine user install rights
425;Will be used to determine where to install the program, shortcuts, ...
426!macro CheckUserInstallRightsMacro UN
427Function ${UN}CheckUserInstallRights
428 Push $0
429 Push $1
430 ClearErrors
431 UserInfo::GetName
432 IfErrors Win9x
433 Pop $0
434 UserInfo::GetAccountType
435 Pop $1
436
437 StrCmp $1 "Admin" 0 +3
438 StrCpy $1 "HKLM"
439 Goto done
440 StrCmp $1 "Power" 0 +3
441 StrCpy $1 "HKLM"
442 Goto done
443 StrCmp $1 "User" 0 +3
444 StrCpy $1 "HKCU"
445 Goto done
446 StrCmp $1 "Guest" 0 +3
447 StrCpy $1 "NONE"
448 Goto done
449 ; Unknown error
450 StrCpy $1 "NONE"
451 Goto done
452
453 Win9x:
454 StrCpy $1 "HKLM"
455
456 done:
457 Exch $1
458 Exch
459 Pop $0
460FunctionEnd
461!macroend
462!insertmacro CheckUserInstallRightsMacro ""
463!insertmacro CheckUserInstallRightsMacro "un."
464
465;Macro to determine if Viking is running before installation/unistallation
466!macro RunCheckMacro UN
467Function ${UN}RunCheck
468 FindProcDLL::FindProc "viking.exe"
469 IntCmp $R0 1 0 notRunning
470 MessageBox MB_OK|MB_ICONEXCLAMATION $(VIKING_IS_RUNNING) /SD IDOK
471 Abort
472 notRunning:
473FunctionEnd
474!macroend
475
0edf62b8
RN
476;!insertmacro RunCheckMacro ""
477;!insertmacro RunCheckMacro "un."
773eb66a
MA
478
479;Installer extra configuration at execution time: language, path, ...
480Function .onInit
481 ;Check if viking installer is already running
482 Push $R0
483 Push $R1
484 Push $R2
485
486 ;Check if viking is running
0edf62b8 487 ;Call RunCheck
773eb66a
MA
488 StrCpy $name "Viking ${VIKING_VERSION}"
489
490 ClearErrors
491 ;Make sure that there was a previous installation
492 ReadRegStr $R0 HKCU "${VIKING_REG_KEY}" "Installer Language"
493
494 ;Preselect the "shortcuts" checkboxes according to the previous installation
495 !insertmacro SelectSection ${SecDesktopShortcut}
496 !insertmacro selectSection ${SecStartMenuShortcut}
497
498 ;Read command line parameters
499
500 ;Read language command line parameters
501 ${GetParameters} $R0
502 ClearErrors
503 ${GetOptions} "$R0" "/L=" $R1
504 IfErrors +3
505 StrCpy $LANGUAGE $R1
506 Goto skip_lang
507
508 ; Select Language
509 ; Display Language selection dialog
510 !insertmacro MUI_LANGDLL_DISPLAY
511 skip_lang:
512
513 ;Read desktop shortcut command line options
514 ClearErrors
515 ${GetOptions} "$R0" "/DS=" $R1
516 IfErrors +8
517 SectionGetFlags ${SecDesktopShortcut} $R2
518 StrCmp "1" $R1 0 +2
519 IntOp $R2 $R2 | ${SF_SELECTED}
520 StrCmp "0" $R1 0 +3
521 IntOp $R1 ${SF_SELECTED} ~
522 IntOp $R2 $R2 & $R1
523 SectionSetFlags ${SecDesktopShortcut} $R2
524
525 ;Read start menu shortcuts command line options
526 ClearErrors
527 ${GetOptions} "$R0" "/SMS=" $R1
528 IfErrors +8
529 SectionGetFlags ${SecStartMenuShortcut} $R2
530 StrCmp "1" $R1 0 +2
531 IntOp $R2 $R2 | ${SF_SELECTED}
532 StrCmp "0" $R1 0 +3
533 IntOp $R1 ${SF_SELECTED} ~
534 IntOp $R2 $R2 & $R1
535 SectionSetFlags ${SecStartMenuShortcut} $R2
536
537 ; If install path was set on the command, use it.
538 StrCmp $INSTDIR "" 0 instdir_done
539
540 ; If viking is currently installed, we should default to where it is currently installed
541 ClearErrors
542 ReadRegStr $INSTDIR HKCU "${VIKING_REG_KEY}" ""
543 IfErrors +2
544 StrCmp $INSTDIR "" 0 instdir_done
545 ClearErrors
546 ReadRegStr $INSTDIR HKLM "${VIKING_REG_KEY}" ""
547 IfErrors +2
548 StrCmp $INSTDIR "" 0 instdir_done
549
550 Call CheckUserInstallRights
551 Pop $R0
552
553 StrCmp $R0 "HKLM" 0 user_dir
b0678771
RN
554 ${If} ${RunningX64}
555 StrCpy $INSTDIR "$PROGRAMFILES64\Viking"
556 ${Else}
557 StrCpy $INSTDIR "$PROGRAMFILES\Viking" ; $PROGRAMFILES32 also works
558 ${EndIf}
559 Goto instdir_done
773eb66a
MA
560 user_dir:
561 Push $SMPROGRAMS
562 ${GetParent} $SMPROGRAMS $R2
563 ${GetParent} $R2 $R2
564 StrCpy $INSTDIR "$R2\Viking"
565
566 instdir_done:
567;LogSet on
568 Pop $R2
569 Pop $R1
570 Pop $R0
571FunctionEnd
572
573Function un.onInit
574 ;Check if viking is running
0edf62b8 575 ;Call un.RunCheck
773eb66a
MA
576 StrCpy $name "Viking ${VIKING_VERSION}"
577
578 ; Get stored language preference
579 !insertmacro MUI_UNGETLANGUAGE
580
581FunctionEnd