]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/include/detection.nsh
updated MiKTeX detection
[features.git] / development / Win32 / packaging / installer / include / detection.nsh
1 /*
2
3 detection.nsh
4
5 Detection of external component locations
6
7 */
8
9 Function SearchExternal
10   Call SearchLaTeX
11   Call SearchBibTeXEditor
12 FunctionEnd
13
14 #--------------------------------
15 # MiKTeX
16
17 Var ReportReturn
18 Var CommandLineOutput
19
20 !macro SEARCH_MIKTEX25
21
22   # Search location of MiKTeX installation using initexmf
23   # Works for version 2.5 and later
24   
25   nsExec::ExecToStack "initexmf.exe --report"
26   Pop $ReportReturn
27   Pop $CommandLineOutput
28
29   ClearErrors
30   ${WordFind2X} $CommandLineOutput "BinDir: " "$\r" "E+1" $PathLaTeX
31   ${If} ${Errors}
32     ClearErrors
33     ${WordFind2X} $CommandLineOutput "CommonInstall: " "$\r" "E+1" $PathLaTeX
34     ${If} ${Errors}
35        StrCpy $PathLaTeX ""
36     ${Else}
37        StrCpy $PathLaTeX "$PathLaTeX\miktex\bin"
38     ${EndIf}
39   ${EndIf}
40
41   ClearErrors
42   ${WordFind2X} $CommandLineOutput "BinDir: " "$\r" "E+1" $PathLaTeX
43   ${If} ${Errors}
44     StrCpy $PathLaTeX ""
45   ${EndIf}
46
47   ${If} $PathLatex == ""
48     ClearErrors
49     ${WordFind2X} $CommandLineOutput "CommonInstall: " "$\r" "E+1" $PathLaTeX
50     ${If} ${Errors}
51       StrCpy $PathLaTeX ""
52     ${Else}
53        StrCpy $PathLaTeX "$PathLaTeX\miktex\bin"
54     ${EndIf}
55   ${EndIf}
56
57   ${If} $PathLatex == ""
58     ClearErrors
59     ${WordFind2X} $CommandLineOutput "UserInstall: " "$\r" "E+1" $PathLaTeX
60     ${If} ${Errors}
61       StrCpy $PathLaTeX ""
62     ${Else}
63        StrCpy $PathLaTeX "$PathLaTeX\miktex\bin"
64     ${EndIf}
65   ${EndIf}
66
67   # Local root
68
69   ClearErrors
70   ${WordFind2X} $CommandLineOutput "CommonData: " "$\r" "E+1" $PathLaTeXLocal
71   ${If} ${Errors}
72     StrCpy $PathLaTeXLocal ""
73   ${EndIf}
74
75   ${If} $PathLatex == ""
76     ClearErrors
77     ${WordFind2X} $CommandLineOutput "UserData: " "$\r" "E+1" $PathLaTeXLocal
78     ${If} ${Errors}
79       StrCpy $PathLaTeXLocal ""
80     ${EndIf}
81   ${EndIf}
82
83 !macroend
84
85 Function SearchLaTeX
86
87   # Search where MikTeX is installed
88   
89   !insertmacro SEARCH_MIKTEX25
90
91   ${IfNot} ${FileExists} "$PathLaTeX\${BIN_LATEX}"
92     StrCpy $PathLateX ""
93   ${EndIf}
94
95 FunctionEnd
96
97 #--------------------------------
98 # JabRef
99
100 Function SearchBibTeXEditor
101
102   # Search where JabRef is installed
103   ReadRegStr $PathBibTeXEditor HKCU "Software\JabRef" "Path"
104
105   ${IfNot} ${FileExists} "$PathBibTeXEditor\${BIN_BIBTEXEDITOR}"
106     ReadRegStr $PathBibTeXEditor HKLM "Software\JabRef" "Path"
107   ${EndIf}
108
109   ${IfNot} ${FileExists} "$PathBibTeXEditor\${BIN_BIBTEXEDITOR}"
110     StrCpy $PathBibTeXEditor ""  
111   ${EndIf}
112
113 FunctionEnd