]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/include/init.nsh
LyX 1.5 Windows installer
[features.git] / development / Win32 / packaging / installer / include / init.nsh
1 /*\r
2 \r
3 Installer and uninstaller initialization\r
4 \r
5 */\r
6 \r
7 ;--------------------------------\r
8 ;Functions\r
9 \r
10 Function CommandLineParameter\r
11 \r
12   Exch $R0\r
13   Push $R1\r
14   Push $R2\r
15   \r
16   StrLen $R1 $R0\r
17   \r
18   Push $CMDLINE\r
19   Push $R0\r
20   Call StrStr\r
21   Pop $R2\r
22   \r
23   StrCpy $R2 $R2 $R1\r
24   \r
25   ${if} $R2 == $R0\r
26     StrCpy $R0 ${TRUE}\r
27   ${else}\r
28     StrCpy $R0 ${FALSE} \r
29   ${endif}\r
30   \r
31   Push $R2\r
32   Push $R1\r
33   Exch $R0\r
34 \r
35 FunctionEnd\r
36 \r
37 Function .onInit\r
38 \r
39   ${unless} ${silent}\r
40     Banner::show /NOUNLOAD "Checking system"\r
41   ${endif}\r
42   \r
43   ;Check all dependencies\r
44   \r
45   Call CheckWindows\r
46   Call CheckPrivileges\r
47   Call LoadInstaller\r
48   Call SearchAll\r
49 \r
50   ${unless} ${silent}\r
51     Banner::destroy\r
52   ${endif}\r
53 \r
54 FunctionEnd\r
55 \r
56 Function un.onInit\r
57 \r
58   Call un.CheckPrivileges\r
59   Call un.LoadUnInstaller\r
60   \r
61 FunctionEnd\r
62 \r
63 Function LoadInstaller\r
64 \r
65   ;Set the correct shell context depending on command line parameter\r
66   ;and priviledges\r
67 \r
68   Push $R0\r
69 \r
70   Push "/CurrentUser"\r
71   Call CommandLineParameter\r
72   Pop $CurrentUserInstall\r
73 \r
74   ${if} $CurrentUserInstall == ${TRUE}\r
75   \r
76     SetShellVarContext current\r
77   \r
78   ${else}\r
79   \r
80     ${if} $AdminOrPowerUser == ${TRUE}\r
81       \r
82       SetShellVarContext all\r
83       \r
84     ${else}\r
85     \r
86       ;Display an error when the /AllUsers command line parameter is used\r
87       ;by a user without Administrator or Power User priviledges\r
88        \r
89       Push "/AllUsers"\r
90       Call CommandLineParameter\r
91       Pop $R0\r
92   \r
93       ${if} $R0 == ${TRUE}\r
94         MessageBox MB_OK|MB_ICONSTOP "You need Administrator or Power User privileges to install ${APP_NAME} for all users."\r
95         Quit\r
96       ${endif}\r
97       \r
98       SetShellVarContext current\r
99     \r
100     ${endif}\r
101     \r
102   ${endif}\r
103   \r
104   ${if} ${silent}\r
105     Call InitUser\r
106   ${endif}\r
107   \r
108   Pop $R0\r
109 \r
110 FunctionEnd\r
111 \r
112 Function un.LoadUnInstaller\r
113 \r
114   ;Set the correct shell context depending on whether LyX has been installed\r
115   ;for the current user or all users\r
116 \r
117   ReadRegStr $R0 HKCU ${APP_REGKEY} ""\r
118   \r
119   ${if} $R0 == $INSTDIR\r
120     StrCpy $CurrentUserInstall ${TRUE}\r
121   ${endif}\r
122 \r
123   ${if} $CurrentUserInstall == ${TRUE}\r
124   \r
125     SetShellVarContext current\r
126   \r
127   ${else}\r
128   \r
129     ${if} $AdminOrPowerUser == ${FALSE}\r
130       MessageBox MB_OK|MB_ICONSTOP "${APP_NAME} has been installed for all users. Therefore you need Administrator or Power User privileges to uninstall."\r
131       Quit\r
132     ${else}\r
133       SetShellVarContext all\r
134     ${endif}\r
135   \r
136   ${endif}\r
137 \r
138 FunctionEnd\r