]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/installer/include/init.nsh
fix for installation by restricted users
[lyx.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       StrCpy $CurrentUserInstall ${TRUE}\r
100     \r
101     ${endif}\r
102     \r
103   ${endif}\r
104   \r
105   ${if} ${silent}\r
106     Call InitUser\r
107   ${endif}\r
108   \r
109   Pop $R0\r
110 \r
111 FunctionEnd\r
112 \r
113 Function un.LoadUnInstaller\r
114 \r
115   ;Set the correct shell context depending on whether LyX has been installed\r
116   ;for the current user or all users\r
117 \r
118   ReadRegStr $R0 HKCU ${APP_REGKEY} ""\r
119   \r
120   ${if} $R0 == $INSTDIR\r
121     StrCpy $CurrentUserInstall ${TRUE}\r
122   ${endif}\r
123 \r
124   ${if} $CurrentUserInstall == ${TRUE}\r
125   \r
126     SetShellVarContext current\r
127   \r
128   ${else}\r
129   \r
130     ${if} $AdminOrPowerUser == ${FALSE}\r
131       MessageBox MB_OK|MB_ICONSTOP "${APP_NAME} has been installed for all users. Therefore you need Administrator or Power User privileges to uninstall."\r
132       Quit\r
133     ${else}\r
134       SetShellVarContext all\r
135     ${endif}\r
136   \r
137   ${endif}\r
138 \r
139 FunctionEnd\r