5 Initialization function
9 #--------------------------------
10 # Installer initialization
14 ${If} ${AtLeastWinVista}
15 StrCpy $PrinterConf "printui.exe"
17 StrCpy $PrinterConf "rundll32.exe printui.dll,PrintUIEntry"
25 ${OrIfNot} ${AtLeastWinXP}
26 MessageBox MB_OK|MB_ICONSTOP "${APP_NAME} ${APP_VERSION} requires Windows XP or later."
30 # check that the installer is not currently running
31 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${BundleExeFile}.Instance") i .r1 ?e'
34 MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
37 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${ExeFile}.Instance") i .r1 ?e'
40 MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
44 # check if LyX is already installed
45 ReadRegStr $0 HKLM "${APP_UNINST_KEY}" "Publisher"
47 MessageBox MB_OK|MB_ICONSTOP "$(StillInstalled)"
51 !insertmacro PRINTER_INIT
52 !insertmacro MULTIUSER_INIT
54 # this can be reset to "true" in section SecDesktop
55 StrCpy $CreateDesktopIcon "false"
56 StrCpy $CreateFileAssociations "false"
60 !ifndef BUNDLE_IMAGEMAGICK & BUNDLE_GHOSTSCRIPT
61 # Warn the user when no Administrator or Power user privileges are available
62 # These privileges are required to install ImageMagick or Ghostscript
63 ${If} $MultiUser.Privileges != "Admin"
64 ${AndIf} $MultiUser.Privileges != "Power"
65 MessageBox MB_OK|MB_ICONEXCLAMATION $(TEXT_NO_PRIVILEDGES)
69 # Show banner while installer is intializating
70 Banner::show /NOUNLOAD "Checking system"
76 !if ${SETUPTYPE} == BUNDLE
77 # don't let the installer sections appear when the programs are already installed
78 ${if} $PathBibTeXEditor != ""
79 SectionSetText 3 "" # hides the corresponding uninstaller section, ${SecInstJabRef}
89 # this function is called at first after starting the uninstaller
92 !insertmacro PRINTER_INIT
93 !insertmacro MULTIUSER_UNINIT
95 # Check that LyX is not currently running
96 FindProcDLL::FindProc "lyx.exe"
98 MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)"
102 # set registry root key
103 ${if} $MultiUser.Privileges == "Admin"
104 ${orif} $MultiUser.Privileges == "Power"
105 SetShellVarContext all
107 SetShellVarContext current
110 # Ascertain whether the user has sufficient privileges to uninstall.
111 # abort when LyX was installed with admin permissions but the user doesn't have administrator privileges
112 ReadRegStr $0 HKLM "${APP_UNINST_KEY}" "DisplayVersion"
114 ${andif} $MultiUser.Privileges != "Admin"
115 ${andif} $MultiUser.Privileges != "Power"
116 MessageBox MB_OK|MB_ICONSTOP "$(UnNotAdminLabel)"
119 # abort when LyX couldn't be found in the registry
120 ${if} $0 == "" # check in HKCU
121 ReadRegStr $0 HKCU "${APP_UNINST_KEY}" "DisplayVersion"
123 MessageBox MB_OK|MB_ICONEXCLAMATION "$(UnNotInRegistryLabel)"
127 # Macro to investigate name of LyX's preferences folders to be able remove them
128 !insertmacro UnAppPreSuff $AppPre $AppSuff # macro from LyXUtils.nsh
130 # test if MiKTeX was installed together with LyX
131 ReadRegStr $0 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
132 ${if} $0 == "Yes${APP_SERIES_KEY}"
133 SectionSetText 2 "MiKTeX" # names the corersponding uninstaller section
134 StrCpy $LaTeXInstalled "MiKTeX"
135 DeleteRegValue HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
137 SectionSetText 2 "" # hides the corresponding uninstaller section
140 # test if JabRef was installed together with LyX
141 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX"
142 ${if} $0 == "Yes${APP_SERIES_KEY}"
143 SectionSetText 3 "JabRef" # names the corersponding uninstaller section
144 StrCpy $JabRefInstalled "Yes"
145 DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX"
147 SectionSetText 3 "" # hides the corresponding uninstaller section
150 # question message if the user really wants to uninstall LyX
151 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" IDYES +2 # continue if yes
156 #--------------------------------
157 # User initialization
162 # COMPONENT can be LaTeX, ImageMagick and Ghostscript
163 !macro EXTERNAL_INIT COMPONENT
165 # APP_REGKEY_SETUP = "Software\${APP_NAME}${APP_SERIES_KEY}\Setup"
166 # where ${APP_NAME}${APP_SERIES_KEY} is something like LyX16
167 ReadRegStr $ComponentPath SHELL_CONTEXT "${APP_REGKEY_SETUP}" "${COMPONENT} Path"
169 # BIN_LATEX etc are defined in settings.nsh
170 ${If} ${FileExists} "$ComponentPath\${BIN_${COMPONENT}}"
171 # set variables like PathLaTeX
172 StrCpy $Path${COMPONENT} $ComponentPath
179 # Get directories of components from registry
181 !insertmacro EXTERNAL_INIT LaTeX
185 ReadRegStr $LyXLangName SHELL_CONTEXT "${APP_REGKEY_SETUP}" "LyX Language"
187 ${If} $LyXLangName != ""
188 StrCpy $LangName $LyXLangName
193 #--------------------------------
194 # visible installer sections
196 Section "!${APP_NAME}" SecCore
199 Section "$(SecFileAssocTitle)" SecFileAssoc
200 StrCpy $CreateFileAssociations "true"
202 Section "$(SecDesktopTitle)" SecDesktop
203 StrCpy $CreateDesktopIcon "true"
206 !if ${SETUPTYPE} == BUNDLE
207 Section /o "$(SecInstJabRefTitle)" SecInstJabRef
209 StrCpy $InstallJabRef "true"
213 # Section descriptions
214 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
215 !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)"
216 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssoc} "$(SecFileAssocDescription)"
217 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
218 !if ${SETUPTYPE} == BUNDLE
219 !insertmacro MUI_DESCRIPTION_TEXT ${SecInstJabRef} "$(SecInstJabRefDescription)"
221 !insertmacro MUI_FUNCTION_DESCRIPTION_END