1 ;_____________________________ HEADER FILE BEGIN ____________________________\r
2 \r
3 # Advanced Uninstall Log NSIS header\r
4 # Version 1.0 2007-01-31\r
5 # By Red Wine (http://nsis.sf.net/User:Red_Wine)\r
6 \r
7 # Usage: See included examples Uninstall_Log_Default_UI.nsi - Uninstall_Log_Modern_UI.nsi\r
8 \r
9 !verbose push\r
10 !verbose 3\r
11 \r
12 !ifndef ADVANCED_UNINSTALL.LOG_NSH\r
13 !define ADVANCED_UNINSTALL.LOG_NSH\r
14 \r
15 !ifndef INSTDIR_REG_ROOT | INSTDIR_REG_KEY\r
16 !error "You must properly define both INSTDIR_REG_ROOT and INSTDIR_REG_KEY"\r
17 !endif\r
18 \r
19 !ifndef UNINSTALL_LOG\r
20 !define UNINSTALL_LOG "Uninstall"\r
21 !endif\r
22 \r
23 !ifndef UNINST_LOG_VERBOSE\r
24 !define UNINST_LOG_VERBOSE "3"\r
25 !endif\r
26 \r
27 !verbose pop\r
28 \r
29 !echo "Advanced Uninstall Log NSIS header v1.0 2007-01-31 by Red Wine (http://nsis.sf.net/User:Red_Wine)"\r
30 \r
31 !verbose push\r
32 !verbose ${UNINST_LOG_VERBOSE}\r
33 \r
34 !define UNINST_EXE "$INSTDIR\${UNINSTALL_LOG}.exe"\r
35 !define UNINST_DAT "$INSTDIR\${UNINSTALL_LOG}.dat"\r
36 !define UNLOG_PART "$PLUGINSDIR\part."\r
37 !define UNLOG_TEMP "$PLUGINSDIR\unlog.tmp"\r
38 !define EXCLU_LIST "$PLUGINSDIR\exclude.tmp"\r
39 !define UNLOG_HEAD "=========== Uninstaller Log please do not edit this file ==========="\r
40 \r
41 var unlog_tmp_0\r
42 var unlog_tmp_1\r
43 var unlog_tmp_2\r
44 var unlog_tmp_3\r
45 var unlog_error\r
46 \r
47 !include FileFunc.nsh\r
48 !include TextFunc.nsh\r
49 \r
50 !insertmacro Locate\r
51 !insertmacro un.Locate\r
52 !insertmacro DirState\r
53 !insertmacro un.DirState\r
54 !insertmacro FileJoin\r
55 !insertmacro TrimNewLines\r
56 !insertmacro un.TrimNewLines\r
57 \r
58 ;.............................. Uninstaller Macros ..............................\r
59 \r
60 !macro UNINSTALL.LOG_BEGIN_UNINSTALL\r
61 !verbose push\r
62 !verbose ${UNINST_LOG_VERBOSE}\r
63 \r
64 IfFileExists "${UNINST_DAT}" +3\r
65 MessageBox MB_ICONSTOP|MB_OK "${UNINST_DAT} not found, unable to perform uninstall." /SD IDOK\r
66 Quit\r
67 \r
68 StrCmp "$PLUGINSDIR" "" 0 +2\r
69 InitPluginsDir\r
70 \r
71 CopyFiles "${UNINST_DAT}" "${UNLOG_TEMP}"\r
72 FileOpen $unlog_tmp_2 "${UNLOG_TEMP}" r\r
73 \r
74 !verbose pop\r
75 !macroend\r
76 \r
77 \r
78 !macro UNINSTALL.LOG_END_UNINSTALL\r
79 !verbose push\r
80 !verbose ${UNINST_LOG_VERBOSE}\r
81 \r
82 FileClose $unlog_tmp_2\r
83 DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "${UNINSTALL_LOG}.dat"\r
84 DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "${UNINSTALL_LOG}Directory"\r
85 \r
86 !verbose pop\r
87 !macroend\r
88 \r
89 \r
90 !macro UNINSTALL.LOG_UNINSTALL TargetDir\r
91 !verbose push\r
92 !verbose ${UNINST_LOG_VERBOSE}\r
93 \r
94 !ifndef INTERACTIVE_UNINSTALL & UNATTENDED_UNINSTALL\r
95 !error "You must insert either Interactive or Unattended Uninstall neither both, neither none."\r
96 !endif\r
97 \r
98 !ifdef INTERACTIVE_UNINSTALL\r
99 GetTempFileName $unlog_tmp_5 "$PLUGINSDIR"\r
100 FileOpen $unlog_tmp_4 "$unlog_tmp_5" a\r
101 !endif\r
102 \r
103 ${PerfomUninstall} "${TargetDir}" "${UnLog_Uninstall_CallBackFunc}"\r
104 \r
105 !ifdef INTERACTIVE_UNINSTALL\r
106 FileClose $unlog_tmp_4\r
107 !endif\r
108 \r
109 !verbose pop\r
110 !macroend\r
111 \r
112 \r
113 !define PerfomUninstall "!insertmacro PERFORMUNINSTALL"\r
114 \r
115 !macro PERFORMUNINSTALL TargetDir UninstCallBackFunc\r
116 !verbose push\r
117 !verbose ${UNINST_LOG_VERBOSE}\r
118 \r
119 !define ID ${__LINE__}\r
120 \r
121 ${un.Locate} "${TargetDir}" "/L=F" "${UninstCallBackFunc}"\r
122 \r
123 loop_${ID}:\r
124 \r
125 StrCpy $unlog_tmp_1 0\r
126 \r
127 ${un.Locate} "${TargetDir}" "/L=DE" "${UninstCallBackFunc}"\r
128 StrCmp $unlog_tmp_1 "0" 0 loop_${ID}\r
129 \r
130 ${un.DirState} "${TargetDir}" $unlog_tmp_0\r
131 StrCmp "$unlog_tmp_0" "0" 0 +2\r
132 RmDir "${TargetDir}"\r
133 \r
134 IfErrors 0 +2\r
135 MessageBox MB_ICONEXCLAMATION|MB_OK "${UNINSTALL_LOG} Log error" /SD IDOK\r
136 \r
137 !undef ID\r
138 \r
139 !verbose pop\r
140 !macroend\r
141 \r
142 \r
143 !macro INTERACTIVE_UNINSTALL\r
144 !verbose push\r
145 !verbose ${UNINST_LOG_VERBOSE}\r
146 \r
147 !ifdef INTERACTIVE_UNINSTALL\r
148 !error "INTERACTIVE_UNINSTALL is already defined"\r
149 !endif\r
150 \r
151 var unlog_tmp_4\r
152 var unlog_tmp_5\r
153 \r
154 !define INTERACTIVE_UNINSTALL\r
155 \r
156 !ifdef INTERACTIVE_UNINSTALL & UNATTENDED_UNINSTALL\r
157 !error "You must insert either Interactive or Unattended Uninstall neither both, neither none."\r
158 !endif\r
159 \r
160 !ifdef UnLog_Uninstall_CallBackFunc\r
161 !undef UnLog_Uninstall_CallBackFunc\r
162 !endif\r
163 \r
164 !ifndef UnLog_Uninstall_CallBackFunc\r
165 !insertmacro UNINSTALL.LOG_UNINSTALL_INTERACTIVE\r
166 !define UnLog_Uninstall_CallBackFunc "un._LocateCallBack_Function_Interactive"\r
167 !endif\r
168 \r
169 !verbose pop\r
170 !macroend\r
171 \r
172 \r
173 !macro UNATTENDED_UNINSTALL\r
174 !verbose push\r
175 !verbose ${UNINST_LOG_VERBOSE}\r
176 \r
177 !ifdef UNATTENDED_UNINSTALL\r
178 !error "UNATTENDED_UNINSTALL is already defined"\r
179 !endif\r
180 \r
181 !define UNATTENDED_UNINSTALL\r
182 \r
183 !ifdef INTERACTIVE_UNINSTALL & UNATTENDED_UNINSTALL\r
184 !error "You must insert either Interactive or Unattended Uninstall neither both, neither none."\r
185 !endif\r
186 \r
187 !ifdef UnLog_Uninstall_CallBackFunc\r
188 !undef UnLog_Uninstall_CallBackFunc\r
189 !endif\r
190 \r
191 !ifndef UnLog_Uninstall_CallBackFunc\r
192 !insertmacro UNINSTALL.LOG_UNINSTALL_UNATTENDED\r
193 !define UnLog_Uninstall_CallBackFunc "un._LocateCallBack_Function_Unattended"\r
194 !endif\r
195 \r
196 !verbose pop\r
197 !macroend\r
198 \r
199 \r
200 !macro UNINSTALL.LOG_UNINSTALL_UNATTENDED\r
201 \r
202 Function un._LocateCallBack_Function_Unattended\r
203 start:\r
204 FileRead $unlog_tmp_2 "$unlog_tmp_3" ${NSIS_MAX_STRLEN}\r
205 ${un.TrimNewLines} "$unlog_tmp_3" "$unlog_tmp_3"\r
206 StrCmp "$unlog_tmp_3" "$R9" islog\r
207 IfErrors nolog\r
208 goto start\r
209 \r
210 islog:\r
211 IfFileExists "$R9\*.*" isdir\r
212 \r
213 isfile:\r
214 Delete "$R9"\r
215 goto end\r
216 \r
217 isdir:\r
218 RmDir "$R9"\r
219 IntOp $unlog_tmp_1 $unlog_tmp_1 + 1\r
220 goto end\r
221 \r
222 nolog:\r
223 ClearErrors\r
224 StrCmp "$R9" "${UNINST_EXE}" isfile\r
225 StrCmp "$R9" "${UNINST_DAT}" isfile\r
226 \r
227 end:\r
228 FileSeek $unlog_tmp_2 0 SET\r
229 Push $unlog_tmp_0\r
230 FunctionEnd\r
231 \r
232 !macroend\r
233 \r
234 \r
235 !macro UNINSTALL.LOG_UNINSTALL_INTERACTIVE\r
236 \r
237 Function un._LocateCallBack_Function_Interactive\r
238 start:\r
239 FileRead $unlog_tmp_2 "$unlog_tmp_3" ${NSIS_MAX_STRLEN}\r
240 ${un.TrimNewLines} "$unlog_tmp_3" "$unlog_tmp_3"\r
241 StrCmp "$unlog_tmp_3" "$R9" islog\r
242 IfErrors nolog\r
243 goto start\r
244 \r
245 islog:\r
246 IfFileExists "$R9\*.*" isdir\r
247 \r
248 isfile:\r
249 Delete "$R9"\r
250 goto end\r
251 \r
252 isdir:\r
253 RmDir "$R9"\r
254 IntOp $unlog_tmp_1 $unlog_tmp_1 + 1\r
255 goto end\r
256 \r
257 nolog:\r
258 ClearErrors\r
259 FileSeek $unlog_tmp_4 0 SET\r
260 read:\r
261 FileRead $unlog_tmp_4 "$unlog_tmp_3"\r
262 ${un.TrimNewLines} "$unlog_tmp_3" "$unlog_tmp_3"\r
263 StrCmp "$unlog_tmp_3" "$R9" end\r
264 IfErrors +2\r
265 goto read\r
266 ClearErrors \r
267 StrCmp "$R9" "${UNINST_EXE}" isfile\r
268 StrCmp "$R9" "${UNINST_DAT}" isfile\r
269 IfFileExists "$R9\*.*" msgdir\r
270 \r
271 MessageBox MB_ICONQUESTION|MB_YESNO \\r
272 'Delete File "$R9"?' /SD IDNO IDYES isfile IDNO nodel\r
273 \r
274 msgdir:\r
275 MessageBox MB_ICONQUESTION|MB_YESNO \\r
276 'Delete Directory "$R9"?' /SD IDNO IDYES isdir IDNO nodel\r
277 \r
278 nodel:\r
279 FileSeek $unlog_tmp_4 0 END\r
280 FileWrite $unlog_tmp_4 "$R9$\r$\n"\r
281 \r
282 end:\r
283 FileSeek $unlog_tmp_2 0 SET\r
284 Push $unlog_tmp_0\r
285 FunctionEnd\r
286 \r
287 !macroend\r
288 \r
289 ;................................. Installer Macros .................................\r
290 \r
291 !macro UNINSTALL.LOG_INSTALL_UNATTENDED\r
292 \r
293 Function _LocateCallBack_Function_Install\r
294 loop:\r
295 FileRead $unlog_tmp_2 "$unlog_tmp_3" ${NSIS_MAX_STRLEN}\r
296 ${TrimNewLines} "$unlog_tmp_3" "$unlog_tmp_3"\r
297 IfErrors 0 +4\r
298 ClearErrors\r
299 FileSeek $unlog_tmp_2 0 SET\r
300 goto next\r
301 StrCmp "$R9" "$unlog_tmp_3" end\r
302 goto loop\r
303 next:\r
304 FileWrite $unlog_tmp_1 "$R9$\r$\n"\r
305 end:\r
306 Push $unlog_tmp_0\r
307 FunctionEnd\r
308 \r
309 !macroend\r
310 \r
311 \r
312 !ifdef UnLog_Install_Func_CallBack\r
313 !undef UnLog_Install_Func_CallBack\r
314 !endif\r
315 \r
316 !ifndef UnLog_Install_Func_CallBack\r
317 !insertmacro UNINSTALL.LOG_INSTALL_UNATTENDED\r
318 !define UnLog_Install_Func_CallBack "_LocateCallBack_Function_Install"\r
319 !endif\r
320 \r
321 \r
322 !macro UNINSTALL.LOG_PREPARE_INSTALL\r
323 !verbose push\r
324 !verbose ${UNINST_LOG_VERBOSE}\r
325 \r
326 Push $0\r
327 Push $1\r
328 ClearErrors\r
329 ReadRegStr "$0" ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "${UNINSTALL_LOG}Directory"\r
330 IfErrors next\r
331 ${DirState} "$0" $1\r
332 StrCmp "$1" "-1" next\r
333 StrCmp "$1" "0" next\r
334 IfFileExists "$0\${UNINSTALL_LOG}.dat" next\r
335 MessageBox MB_ICONEXCLAMATION|MB_OK \\r
336 "Previous installation detected at $0.$\n\\r
337 Required file ${UNINSTALL_LOG}.dat is missing.$\n$\nIt is highly recommended \\r
338 to select an empty directory and perform a fresh installation." /SD IDOK\r
339 StrCpy $unlog_error "error"\r
340 \r
341 next:\r
342 ClearErrors\r
343 StrCmp "$PLUGINSDIR" "" 0 +2\r
344 InitPluginsDir\r
345 \r
346 GetTempFileName "$1"\r
347 FileOpen $0 "$1" w\r
348 FileWrite $0 "${UNLOG_HEAD}$\r$\n"\r
349 FileClose $0\r
350 Rename "$1" "${UNLOG_TEMP}"\r
351 Pop $1\r
352 Pop $0\r
353 \r
354 !verbose pop\r
355 !macroend\r
356 \r
357 \r
358 !macro UNINSTALL.LOG_UPDATE_INSTALL\r
359 !verbose push\r
360 !verbose ${UNINST_LOG_VERBOSE}\r
361 \r
362 Delete "${UNINST_DAT}"\r
363 Rename "${UNLOG_TEMP}" "${UNINST_DAT}"\r
364 WriteUninstaller "${UNINST_EXE}"\r
365 WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "${UNINSTALL_LOG}.dat" "${UNINST_DAT}"\r
366 WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "${UNINSTALL_LOG}Directory" "$INSTDIR"\r
367 \r
368 !verbose pop\r
369 !macroend\r
370 \r
371 \r
372 !define uninstall.log_install "!insertmacro UNINSTALL.LOG_INSTALL"\r
373 \r
374 !macro UNINSTALL.LOG_INSTALL FileOpenWrite FileOpenRead TargetDir\r
375 !verbose push\r
376 !verbose ${UNINST_LOG_VERBOSE}\r
377 \r
378 FileOpen $unlog_tmp_1 "${FileOpenWrite}" w\r
379 FileOpen $unlog_tmp_2 "${FileOpenRead}" r\r
380 \r
381 ${Locate} "${TargetDir}" "/L=FD" "${UnLog_Install_Func_CallBack}"\r
382 \r
383 StrCmp $unlog_error "error" 0 +2\r
384 ClearErrors\r
385 \r
386 IfErrors 0 +2\r
387 MessageBox MB_ICONEXCLAMATION|MB_OK "Error creating ${UNINSTALL_LOG} Log." /SD IDOK\r
388 \r
389 FileClose $unlog_tmp_1\r
390 FileClose $unlog_tmp_2\r
391 \r
392 !verbose pop\r
393 !macroend\r
394 \r
395 \r
396 !define uninstall.log_mergeID "!insertmacro UNINSTALL.LOG_MERGE"\r
397 \r
398 !macro UNINSTALL.LOG_MERGE UnlogPart\r
399 !verbose push\r
400 !verbose ${UNINST_LOG_VERBOSE}\r
401 \r
402 ${FileJoin} "${UNLOG_TEMP}" "${UnlogPart}" "${UNLOG_TEMP}"\r
403 \r
404 !verbose pop\r
405 !macroend\r
406 \r
407 \r
408 !macro UNINSTALL.LOG_OPEN_INSTALL\r
409 !verbose push\r
410 !verbose ${UNINST_LOG_VERBOSE}\r
411 \r
412 StrCmp $unlog_error "error" +2\r
413 ${uninstall.log_install} "${EXCLU_LIST}" "${UNINST_DAT}" "$OUTDIR"\r
414 \r
415 !verbose pop\r
416 !macroend\r
417 \r
418 \r
419 !macro UNINSTALL.LOG_CLOSE_INSTALL\r
420 !verbose push\r
421 !verbose ${UNINST_LOG_VERBOSE}\r
422 \r
423 !define ID ${__LINE__}\r
424 \r
425 ${uninstall.log_install} "${UNLOG_PART}${ID}" "${EXCLU_LIST}" "$OUTDIR"\r
426 ${uninstall.log_mergeID} "${UNLOG_PART}${ID}"\r
427 \r
428 !undef ID ${__LINE__}\r
429 \r
430 !verbose pop\r
431 !macroend\r
432 \r
433 !endif\r
434 \r
435 !verbose pop\r
436 ;_____________________________ HEADER FILE END ____________________________\r
437 \r