]> git.street.me.uk Git - andy/viking.git/blob - win32/installer/viking-installer.nsi
Some spelling fixes in a comment
[andy/viking.git] / win32 / installer / viking-installer.nsi
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
8 Var name
9
10 ;--------------------------------
11 ;Configuration
12 ;Needs to be 4 numbers:  W.X.Y.Z
13 !define VIKING_VERSION  "1.6.1.0"
14
15 ;The name var is set in .onInit
16 Name $name
17
18 ;Allow overiding location of binary components for the install
19 !ifndef BINARIES
20   !define BINARIES ".\bin"
21 !endif
22
23 OutFile "viking-${VIKING_VERSION}.exe"
24
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
28 ShowInstDetails show
29 ShowUninstDetails show
30 SetDateSave 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"
38 !include "x64.nsh"
39 ;; http://nsis.sourceforge.net/File_Association
40 !include "FileAssociation.nsh"
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
61 ;--------------------------------
62 ;Version resource
63 VIProductVersion "${VIKING_VERSION}"
64 VIAddVersionKey "ProductName" "Viking"
65 VIAddVersionKey "FileVersion" "${VIKING_VERSION}"
66 VIAddVersionKey "ProductVersion" "${VIKING_VERSION}"
67 VIAddVersionKey "LegalCopyright" ""
68 VIAddVersionKey "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
101   !insertmacro MUI_PAGE_LICENSE                 "${BINARIES}\COPYING_GPL.txt"
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"
124   !insertmacro MUI_LANGUAGE "Spanish"
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"
135   !insertmacro VIKING_MACRO_INCLUDE_LANGFILE "SPANISH"          "${VIKING_NSIS_INCLUDE_PATH}\translations\spanish.nsh"
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
150 LicenseData "${BINARIES}\COPYING_GPL.txt"
151 LicenseForceSelection checkbox
152
153 ;--------------------------------
154 ;Uninstall any old version of Viking
155
156 Section -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:
211 SectionEnd
212
213
214 ;--------------------------------
215 ;Viking Install Section
216
217 Section $(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"
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:
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
245     ; Common settings
246     WriteRegStr SHCTX ${VIKING_REG_KEY} "" "$INSTDIR"
247     WriteRegStr SHCTX ${VIKING_REG_KEY} "Version" "${VIKING_VERSION}"
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}
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)
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
272     File /r ${BINARIES}\share
273     File /r ${BINARIES}\lib
274
275     ; Estimate install size based on files in $INSTDIR
276     ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
277     IntFmt $0 "0x%08X" $0
278     WriteRegDWORD SHCTX "${VIKING_UNINSTALL_KEY}" "EstimatedSize" "$0"
279
280     ; If we don't have install rights we're done
281     StrCmp $R0 "NONE" done
282     SetOverwrite off
283
284     ; write out uninstaller
285     SetOverwrite on
286     WriteUninstaller "$INSTDIR\${VIKING_UNINST_EXE}"
287     SetOverwrite off
288
289     ; Always associate Viking file type
290     ${registerExtension} "$INSTDIR\viking.exe" ".vik" "Viking File"
291   done:
292 SectionEnd ; end of default Viking section
293
294 ;--------------------------------
295 ;Shortcuts
296
297 SectionGroup /e $(VIKING_SHORTCUTS_SECTION_TITLE) SecShortcuts
298   ;Desktop shortcuts
299   Section /o $(VIKING_DESKTOP_SHORTCUT_SECTION_TITLE) SecDesktopShortcut
300     SetOverwrite on
301     CreateShortCut "$DESKTOP\Viking.lnk" "$INSTDIR\viking.exe"
302     SetOverwrite off
303   SectionEnd
304   ;Start menu shortcuts
305   Section $(VIKING_STARTMENU_SHORTCUT_SECTION_TITLE) SecStartMenuShortcut
306     SetOverwrite on
307     CreateDirectory "$SMPROGRAMS\Viking"
308     CreateShortCut "$SMPROGRAMS\Viking\Viking.lnk" "$INSTDIR\viking.exe"
309     CreateShortCut "$SMPROGRAMS\Viking\User Manual.lnk" "$INSTDIR\viking.pdf"
310     CreateShortCut "$SMPROGRAMS\Viking\Uninstall.lnk" "$INSTDIR\viking-uninst.exe"
311     SetOverwrite off
312   SectionEnd
313 SectionGroupEnd
314
315 ;--------------------------------
316 ;File association
317
318 Section $(VIKING_FILE_ASSOCIATION_SECTION_TITLE) SecFileAssociation
319   ${registerExtension} "$INSTDIR\viking.exe" ".gpx" "GPX File"
320 SectionEnd
321
322 ;--------------------------------
323 ; GPSBabel Install Section
324 ;
325 Section $(VIKING_GPSBABEL_SECTION_TITLE) SecGPSBabel
326   File "${BINARIES}\Optional\GPSBabel-1.5.2-Setup.exe"
327   ExecWait '"$INSTDIR\GPSBabel-1.5.2-Setup.exe" /SILENT'
328   Delete "$INSTDIR\GPSBabel-1.5.2-Setup.exe"
329 SectionEnd
330
331 ;--------------------------------
332 ;Uninstaller Section
333
334
335 Section Uninstall
336   Call un.CheckUserInstallRights
337   Pop $R0
338   StrCmp $R0 "NONE" no_rights
339   StrCmp $R0 "HKCU" try_hkcu try_hklm
340
341   try_hkcu:
342     ReadRegStr $R0 HKCU ${VIKING_REG_KEY} ""
343     StrCmp $R0 $INSTDIR 0 cant_uninstall
344       ; HKCU install path matches our INSTDIR so uninstall
345       DeleteRegKey HKCU ${VIKING_REG_KEY}
346       DeleteRegKey HKCU "${VIKING_UNINSTALL_KEY}"
347       Goto cont_uninstall
348
349   try_hklm:
350     ReadRegStr $R0 HKLM ${VIKING_REG_KEY} ""
351     StrCmp $R0 $INSTDIR 0 try_hkcu
352       ; HKLM install path matches our INSTDIR so uninstall
353       DeleteRegKey HKLM ${VIKING_REG_KEY}
354       DeleteRegKey HKLM "${VIKING_UNINSTALL_KEY}"
355       DeleteRegKey HKLM "${HKLM_APP_PATHS_KEY}"
356       ; Sets start menu and desktop scope to all users..
357       SetShellVarContext "all"
358
359   cont_uninstall:
360
361     ; http://nsis.sourceforge.net/Docs/Chapter4.html
362     ; Don't use:
363     ;RMDir /r "$INSTDIR"
364     ; Warning: is not safe. Can delete entire Program Files directory!
365
366     ; TODO try this method instead:
367     ; http://nsis.sourceforge.net/Uninstall_only_installed_files
368
369     ; Specific remove files
370     ; Thus alsos leaves any files the user has saved (particularly .vik or .gpx) into the Viking directory
371     Delete "$INSTDIR\viking-cache.py"
372     Delete "$INSTDIR\viking.pdf"
373     Delete "$INSTDIR\viking_icon.ico"
374     Delete "$INSTDIR\*.exe"
375     Delete "$INSTDIR\*.dll"
376     Delete "$INSTDIR\*.txt"
377     Delete "$INSTDIR\magic.mgc"
378     Delete "$INSTDIR\data\*txt"
379     Delete "$INSTDIR\data\*xml"
380     RMDir "$INSTDIR\data"
381     RMDir /r "$INSTDIR\locale"
382     RMDir /r "$INSTDIR\lib"
383     RMDir /r "$INSTDIR\share"
384     RMDir "$INSTDIR"
385
386     ; Shortcuts..
387     Delete "$DESKTOP\Viking.lnk"
388
389     ; File association
390     ${unregisterExtension} ".vik" "Viking File"
391     ${unregisterExtension} ".gpx" "GPX File"
392
393     Goto done
394
395   cant_uninstall:
396     MessageBox MB_OK $(un.VIKING_UNINSTALL_ERROR_1) /SD IDOK
397     Quit
398
399   no_rights:
400     MessageBox MB_OK $(un.VIKING_UNINSTALL_ERROR_2) /SD IDOK
401     Quit
402
403   done:
404 SectionEnd ; end of uninstall section
405
406 ;--------------------------------
407 ;Descriptions
408 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
409
410   !insertmacro MUI_DESCRIPTION_TEXT ${SecViking} \
411         $(VIKING_SECTION_DESCRIPTION)
412   !insertmacro MUI_DESCRIPTION_TEXT ${SecShortcuts} \
413         $(VIKING_SHORTCUTS_SECTION_DESCRIPTION)
414   !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktopShortcut} \
415         $(VIKING_DESKTOP_SHORTCUT_DESC)
416   !insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenuShortcut} \
417         $(VIKING_STARTMENU_SHORTCUT_DESC)
418   !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssociation} \
419         $(VIKING_FILE_ASSOCIATION_DESC)
420   !insertmacro MUI_DESCRIPTION_TEXT ${SecGPSBabel} \
421         $(VIKING_INSTALL_GPSBABEL_DESC)
422
423 !insertmacro MUI_FUNCTION_DESCRIPTION_END
424
425 ;--------------------------------
426 ;Functions
427
428 ;Macro to determine user install rights
429 ;Will be used to determine where to install the program, shortcuts, ...
430 !macro CheckUserInstallRightsMacro UN
431 Function ${UN}CheckUserInstallRights
432   Push $0
433   Push $1
434   ClearErrors
435   UserInfo::GetName
436   IfErrors Win9x
437   Pop $0
438   UserInfo::GetAccountType
439   Pop $1
440
441   StrCmp $1 "Admin" 0 +3
442     StrCpy $1 "HKLM"
443     Goto done
444   StrCmp $1 "Power" 0 +3
445     StrCpy $1 "HKLM"
446     Goto done
447   StrCmp $1 "User" 0 +3
448     StrCpy $1 "HKCU"
449     Goto done
450   StrCmp $1 "Guest" 0 +3
451     StrCpy $1 "NONE"
452     Goto done
453   ; Unknown error
454   StrCpy $1 "NONE"
455   Goto done
456
457   Win9x:
458     StrCpy $1 "HKLM"
459
460   done:
461     Exch $1
462     Exch
463     Pop $0
464 FunctionEnd
465 !macroend
466 !insertmacro CheckUserInstallRightsMacro ""
467 !insertmacro CheckUserInstallRightsMacro "un."
468
469 ;Macro to determine if Viking is running before installation/unistallation
470 !macro RunCheckMacro UN
471 Function ${UN}RunCheck
472   FindProcDLL::FindProc "viking.exe"
473   IntCmp $R0 1 0 notRunning
474     MessageBox MB_OK|MB_ICONEXCLAMATION $(VIKING_IS_RUNNING) /SD IDOK
475     Abort
476   notRunning:
477 FunctionEnd
478 !macroend
479
480 ;!insertmacro RunCheckMacro ""
481 ;!insertmacro RunCheckMacro "un."
482
483 ;Installer extra configuration at execution time: language, path, ...
484 Function .onInit
485   ;Check if viking installer is already running
486   Push $R0
487   Push $R1
488   Push $R2
489
490   ;Check if viking is running
491   ;Call RunCheck
492   StrCpy $name "Viking ${VIKING_VERSION}"
493
494   ClearErrors
495   ;Make sure that there was a previous installation
496   ReadRegStr $R0 HKCU "${VIKING_REG_KEY}" "Installer Language"
497   
498   ;Preselect the "shortcuts" checkboxes according to the previous installation
499   !insertmacro SelectSection ${SecDesktopShortcut}
500   !insertmacro selectSection ${SecStartMenuShortcut}
501   
502   ;Read command line parameters
503   
504   ;Read language command line parameters
505   ${GetParameters} $R0
506   ClearErrors
507   ${GetOptions} "$R0" "/L=" $R1
508   IfErrors +3
509   StrCpy $LANGUAGE $R1
510   Goto skip_lang
511
512   ; Select Language
513     ; Display Language selection dialog
514     !insertmacro MUI_LANGDLL_DISPLAY
515     skip_lang:
516
517   ;Read desktop shortcut command line options
518   ClearErrors
519   ${GetOptions} "$R0" "/DS=" $R1
520   IfErrors +8
521   SectionGetFlags ${SecDesktopShortcut} $R2
522   StrCmp "1" $R1 0 +2
523   IntOp $R2 $R2 | ${SF_SELECTED}
524   StrCmp "0" $R1 0 +3
525   IntOp $R1 ${SF_SELECTED} ~
526   IntOp $R2 $R2 & $R1
527   SectionSetFlags ${SecDesktopShortcut} $R2
528
529   ;Read start menu shortcuts command line options
530   ClearErrors
531   ${GetOptions} "$R0" "/SMS=" $R1
532   IfErrors +8
533   SectionGetFlags ${SecStartMenuShortcut} $R2
534   StrCmp "1" $R1 0 +2
535   IntOp $R2 $R2 | ${SF_SELECTED}
536   StrCmp "0" $R1 0 +3
537   IntOp $R1 ${SF_SELECTED} ~
538   IntOp $R2 $R2 & $R1
539   SectionSetFlags ${SecStartMenuShortcut} $R2
540
541   ; If install path was set on the command, use it.
542   StrCmp $INSTDIR "" 0 instdir_done
543
544   ;  If viking is currently installed, we should default to where it is currently installed
545   ClearErrors
546   ReadRegStr $INSTDIR HKCU "${VIKING_REG_KEY}" ""
547   IfErrors +2
548   StrCmp $INSTDIR "" 0 instdir_done
549   ClearErrors
550   ReadRegStr $INSTDIR HKLM "${VIKING_REG_KEY}" ""
551   IfErrors +2
552   StrCmp $INSTDIR "" 0 instdir_done
553
554   Call CheckUserInstallRights
555   Pop $R0
556
557   StrCmp $R0 "HKLM" 0 user_dir
558   ${If} ${RunningX64}
559     StrCpy $INSTDIR "$PROGRAMFILES64\Viking"
560   ${Else}
561     StrCpy $INSTDIR "$PROGRAMFILES\Viking" ; $PROGRAMFILES32 also works
562   ${EndIf}
563   Goto instdir_done
564   user_dir:
565     Push $SMPROGRAMS
566     ${GetParent} $SMPROGRAMS $R2
567     ${GetParent} $R2 $R2
568     StrCpy $INSTDIR "$R2\Viking"
569
570   instdir_done:
571 ;LogSet on
572   Pop $R2
573   Pop $R1
574   Pop $R0
575 FunctionEnd
576
577 Function un.onInit
578   ;Check if viking is running
579   ;Call un.RunCheck
580   StrCpy $name "Viking ${VIKING_VERSION}"
581
582   ; Get stored language preference
583   !insertmacro MUI_UNGETLANGUAGE
584
585 FunctionEnd