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