1 # This script contains the following functions:
3 # - LaTeXCheck (check installed LaTeX-system),
4 # (only used by Small and Complete installer), uses:
10 # - un.DelAppPathSub and UnAppPreSuff,
11 # (delete the folder ~\Documents and Settings\username\Application Data\LyX for all users), uses:
19 # - CheckAppPathPreferences (replaces the old install folder name with the new one in the preferences files)
20 # (used by Update installer), uses:
23 # - IsUserAdmin (checks if user is admin)
25 # - FileCheck (checks if a given file exists)
27 #--------------------------
29 !macro StrPointer FindStr SearchStr Pointer
30 # searches for a string/character (SearchStr) in another string (FindStr)
31 # and returns the number of the character in the FindStr where the SearchStr was found (Pointer)
32 # if nothing was found or the search is impossible the Pointer is set to -1
34 StrLen $R2 ${SearchStr}
41 IntCmp $R4 $R2 loopA NotFound
43 StrCpy $R3 ${FindStr} $R2 $R5
44 StrCmp $R3 ${SearchStr} Found
46 IntCmp $R4 $R5 loopA NotFound
52 StrCpy ${Pointer} "-1"
57 #--------------------------------
60 !insertmacro StrPointer $String $Search $Pointer
63 #--------------------------------
65 !macro RevStrPointer FindStr SearchStr Pointer
66 # searches for a string/character (SearchStr) in another string (FindStr) in reverse order
67 # and returns the number of the character in the FindStr where the SearchStr was found (Pointer)
68 # if nothing was found or the search is impossible the Pointer is set to +1
70 StrLen $R2 ${SearchStr}
76 IntCmp $R4 $R2 loopA NotFound
79 StrCpy $R3 ${FindStr} $R2 $R5
80 StrCmp $R3 ${SearchStr} Found
82 IntCmp "$R5" "-$R4" loopA NotFound
88 StrCpy ${Pointer} "+1"
93 #--------------------------------
96 !insertmacro RevStrPointer $String $Search $Pointer
99 #--------------------------------
101 !macro AppPreSuff AppPre AppSuff
102 # the APPDATA path for a local user has for WinXP and 2000 the following structure:
103 # C:\Documents and Settings\username\Application Data
104 # for Win Vista the structure is:
105 # C:\Users\username\AppData\Roaming
106 # this macro saves the "C:\Documents and Settings\" substring into the variable "AppPre"
107 # and the "Application Data" substring into the variable "AppSuff"
109 # switch temporarily to local user because the all users application data path is in
110 # Vista only C:\ProgramData
111 SetShellVarContext current
112 StrCpy $String "$APPDATA"
113 Var /GLOBAL APPDATemp
114 StrCpy $APPDATemp "$APPDATA"
115 ${If} $MultiUser.Privileges == "Admin"
116 ${OrIf} $MultiUser.Privileges == "Power"
117 SetShellVarContext all # move back to all users
120 Call StrPoint # search for the first "\"
121 IntOp $Pointer $Pointer + 1 # jump after the "\"
122 StrCpy $String $String "" $Pointer # cut off the part before the first "\"
124 Call StrPoint # search for the second "\"
125 IntOp $0 $0 + $Pointer # $0 is now the pointer to the second "\" in the APPDATA string
126 StrCpy ${AppPre} $APPDATemp $0 # save the part before the second "\"
127 IntOp $Pointer $Pointer + 1 # jump after the "\"
128 StrCpy $String $String "" $Pointer # cut off the part before the second "\"
129 Call StrPoint # search for the third "\"
130 IntOp $Pointer $Pointer + 1 # jump after the "\"
131 StrCpy ${AppSuff} $String "" $Pointer # save the part after the third "\"
135 #--------------------------------
138 # deletes a subfolder of the APPDATA path for all users
139 # used by the function "un.getUsers"
149 IntCmp $R1 $R2 get 0 get
150 StrCpy $R3 $R0 1 -$R1
162 #--------------------------------
165 # reads the subfolders of the "Documents and Settings" folder to get a list of the users
172 FindFirst $R0 $R1 "$R2\*"
173 StrCmp $R1 "" findend 0
175 IfFileExists "$R2\$R1\*.*" 0 notDir
176 StrCmp $R1 "." notDir
177 StrCmp $R1 ".." notDir
178 StrCmp $R1 "All Users" notDir
179 StrCmp $R1 "Default User" notDir
180 StrCmp $R1 "All Users.WINNT" notDir
181 StrCmp $R1 "Default User.WINNT" notDir
185 StrCmp $R1 "" findend 0
192 #--------------------------------
194 Function un.GetParentA
195 # deletes a subfolder of the APPDATA path for all users
196 # used by the function "un.getUsers"
206 IntCmp $R1 $R2 get 0 get
207 StrCpy $R3 $R0 1 -$R1
219 #--------------------------------
222 # reads the subfolders of the "Documents and Settings" folder to get a list of the users
229 FindFirst $R0 $R1 "$R2\*"
230 StrCmp $R1 "" findend 0
232 IfFileExists "$R2\$R1\*.*" 0 notDir
233 StrCmp $R1 "." notDir
234 StrCmp $R1 ".." notDir
235 StrCmp $R1 "All Users" notDir
236 StrCmp $R1 "Default User" notDir
237 StrCmp $R1 "All Users.WINNT" notDir
238 StrCmp $R1 "Default User.WINNT" notDir
242 StrCmp $R1 "" findend 0
249 #--------------------------------
252 !insertmacro StrPointer $String $Search $Pointer
255 #--------------------------------
257 !macro UnAppPreSuff AppPre AppSuff
258 # the APPDATA path for a local user has for WinXP and 2000 the following structure:
259 # C:\Documents and Settings\username\Application Data
260 # for Win Vista the structure is:
261 # C:\Users\username\AppData\Roaming
262 # this macro saves the "C:\Documents and Settings\" substring into the variable "AppPre"
263 # and the "Application Data" substring into the variable "AppSuff"
265 SetShellVarContext current # switch temoprarily to local user
266 StrCpy $String "$APPDATA"
267 StrCpy $APPDATemp "$APPDATA"
268 ${if} $MultiUser.Privileges == "Admin"
269 ${orif} $MultiUser.Privileges == "Power"
270 SetShellVarContext all # move back to all users
273 Call un.StrPoint # search for the first "\"
274 IntOp $Pointer $Pointer + 1 # jump after the "\"
275 StrCpy $String $String "" $Pointer # cut off the part before the first "\"
277 Call un.StrPoint # search for the second "\"
278 IntOp $0 $0 + $Pointer # $0 is now the pointer to the second "\" in the APPDATA string
279 StrCpy ${AppPre} $APPDATemp $0 # save the part before the second "\"
280 IntOp $Pointer $Pointer + 1 # jump after the "\"
281 StrCpy $String $String "" $Pointer # cut off the part before the second "\"
282 Call un.StrPoint # search for the third "\"
283 IntOp $Pointer $Pointer + 1 # jump after the "\"
284 StrCpy ${AppSuff} $String "" $Pointer # save the part after the third "\"
288 #--------------------------------
290 Function un.DelAppPathSub
291 # deletes a subfolder of the APPDATA path for all users
293 # get list of all users
299 StrCpy $UserList $R3 "" 1 # cut off the "|" at the end of the list
305 # the usernames in the list of all users is separated by "|"
307 StrCpy $String "$UserList"
309 Call un.StrPoint # search for the "|"
310 StrCmp $Pointer "-1" ready
311 StrCpy $0 $UserList $Pointer # $0 contains now the username
312 IntOp $Pointer $Pointer + 1 # jump after the "|"
313 StrCpy $UserList $UserList "" $Pointer # cut off the first username in the list
314 # generate the string for the current user
315 # AppPre and AppSuff are generated in the macro "AppPreSuff"
316 RMDir /r "$AppPre\$0\$AppSuff\$AppSubfolder" # delete the folder
320 RMDir /r "$AppPre\$0\$AppSuff\$AppSubfolder" # delete the folder
324 #--------------------------------
326 !macro FileCheck Result FileName FilePath
327 # checks if a file exists, returns "True" or "False"
333 FileOpen $0 "${Filepath}\${FileName}" r
346 #------------------------------------------
349 # searches the string "$Search" in the string "$String" and extracts the path around it
350 # the extracted path is checked if the file "latex.exe" is in it
355 ${if} $Pointer == "-1" # if nothing was found
359 IntOp $3 $3 - $Pointer
360 StrCpy $4 $String $3 "-$3" # $4 is now the part behind the $Search string
361 StrCpy $String $String $Pointer # $String is now the part before the $Search string
362 StrCpy $Search ":" # search for the ":" after the first previous drive letter
364 IntOp $Pointer $Pointer - 1 # jump before the ":" to the drive letter
365 StrCpy $Pointer $Pointer "" 1 # cut of the "-" sign
366 StrCpy $PathLaTeX $String $Pointer "-$Pointer"
368 StrCpy $Search ";" # search for the following ";" that separates the different paths
370 ${if} $Pointer != "-1" # if something was found
371 StrCpy $String $String $Pointer
373 StrCpy $PathLaTeX "$PathLaTeX$String"
374 # check if the latex.exe exists in the $PathLaTeX folder
375 !insertmacro FileCheck $5 "latex.exe" "$PathLaTeX"
376 ${if} $5 == "False" # delete the entry with the wrong path to the latex.exe and try again
379 StrCpy $String $4 "" $3
380 ${if} $2 == "TeXLive"
381 StrCpy $Search "TeXLive"
383 StrCpy $Search "miktex"