1 # Advanced Uninstall Log NSIS header
2 # Version 1.0 2007-01-31
3 # By Red Wine (http://nsis.sf.net/User:Red_Wine)
5 # Usage: See included examples Uninstall_Log_Default_UI.nsi - Uninstall_Log_Modern_UI.nsi
10 !ifndef ADVANCED_UNINSTALL.LOG_NSH
11 !define ADVANCED_UNINSTALL.LOG_NSH
13 !ifndef INSTDIR_REG_ROOT | INSTDIR_REG_KEY
14 !error "You must properly define both INSTDIR_REG_ROOT and INSTDIR_REG_KEY"
18 !define UNINSTALL_LOG "Uninstall"
21 !ifndef UNINST_LOG_VERBOSE
22 !define UNINST_LOG_VERBOSE "3"
27 !echo "Advanced Uninstall Log NSIS header v1.0 2007-01-31 by Red Wine (http://nsis.sf.net/User:Red_Wine)"
30 !verbose ${UNINST_LOG_VERBOSE}
32 !define UNINST_EXE "$INSTDIR\${UNINSTALL_LOG}.exe"
33 !define UNINST_DAT "$INSTDIR\${UNINSTALL_LOG}.dat"
34 !define UNLOG_PART "$PLUGINSDIR\part."
35 !define UNLOG_TEMP "$PLUGINSDIR\unlog.tmp"
36 !define EXCLU_LIST "$PLUGINSDIR\exclude.tmp"
37 !define UNLOG_HEAD "=========== Uninstaller Log please do not edit this file ==========="
49 !insertmacro un.Locate
51 !insertmacro un.DirState
53 !insertmacro TrimNewLines
54 !insertmacro un.TrimNewLines
56 ;.............................. Uninstaller Macros ..............................
58 !macro UNINSTALL.LOG_BEGIN_UNINSTALL
60 !verbose ${UNINST_LOG_VERBOSE}
62 IfFileExists "${UNINST_DAT}" +3
63 MessageBox MB_ICONSTOP|MB_OK "${UNINST_DAT} not found, unable to perform uninstall." /SD IDOK
66 StrCmp "$PLUGINSDIR" "" 0 +2
69 CopyFiles "${UNINST_DAT}" "${UNLOG_TEMP}"
70 FileOpen $unlog_tmp_2 "${UNLOG_TEMP}" r
76 !macro UNINSTALL.LOG_END_UNINSTALL
78 !verbose ${UNINST_LOG_VERBOSE}
80 FileClose $unlog_tmp_2
81 DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "${UNINSTALL_LOG}.dat"
82 DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "${UNINSTALL_LOG}Directory"
88 !macro UNINSTALL.LOG_UNINSTALL TargetDir
90 !verbose ${UNINST_LOG_VERBOSE}
92 !ifndef INTERACTIVE_UNINSTALL & UNATTENDED_UNINSTALL
93 !error "You must insert either Interactive or Unattended Uninstall neither both, neither none."
96 !ifdef INTERACTIVE_UNINSTALL
97 GetTempFileName $unlog_tmp_5 "$PLUGINSDIR"
98 FileOpen $unlog_tmp_4 "$unlog_tmp_5" a
101 ${PerfomUninstall} "${TargetDir}" "${UnLog_Uninstall_CallBackFunc}"
103 !ifdef INTERACTIVE_UNINSTALL
104 FileClose $unlog_tmp_4
111 !define PerfomUninstall "!insertmacro PERFORMUNINSTALL"
113 !macro PERFORMUNINSTALL TargetDir UninstCallBackFunc
115 !verbose ${UNINST_LOG_VERBOSE}
117 !define ID ${__LINE__}
119 ${un.Locate} "${TargetDir}" "/L=F" "${UninstCallBackFunc}"
123 StrCpy $unlog_tmp_1 0
125 ${un.Locate} "${TargetDir}" "/L=DE" "${UninstCallBackFunc}"
126 StrCmp $unlog_tmp_1 "0" 0 loop_${ID}
128 ${un.DirState} "${TargetDir}" $unlog_tmp_0
129 StrCmp "$unlog_tmp_0" "0" 0 +2
133 MessageBox MB_ICONEXCLAMATION|MB_OK "${UNINSTALL_LOG} Log error" /SD IDOK
141 !macro INTERACTIVE_UNINSTALL
143 !verbose ${UNINST_LOG_VERBOSE}
145 !ifdef INTERACTIVE_UNINSTALL
146 !error "INTERACTIVE_UNINSTALL is already defined"
152 !define INTERACTIVE_UNINSTALL
154 !ifdef INTERACTIVE_UNINSTALL & UNATTENDED_UNINSTALL
155 !error "You must insert either Interactive or Unattended Uninstall neither both, neither none."
158 !ifdef UnLog_Uninstall_CallBackFunc
159 !undef UnLog_Uninstall_CallBackFunc
162 !ifndef UnLog_Uninstall_CallBackFunc
163 !insertmacro UNINSTALL.LOG_UNINSTALL_INTERACTIVE
164 !define UnLog_Uninstall_CallBackFunc "un._LocateCallBack_Function_Interactive"
171 !macro UNATTENDED_UNINSTALL
173 !verbose ${UNINST_LOG_VERBOSE}
175 !ifdef UNATTENDED_UNINSTALL
176 !error "UNATTENDED_UNINSTALL is already defined"
179 !define UNATTENDED_UNINSTALL
181 !ifdef INTERACTIVE_UNINSTALL & UNATTENDED_UNINSTALL
182 !error "You must insert either Interactive or Unattended Uninstall neither both, neither none."
185 !ifdef UnLog_Uninstall_CallBackFunc
186 !undef UnLog_Uninstall_CallBackFunc
189 !ifndef UnLog_Uninstall_CallBackFunc
190 !insertmacro UNINSTALL.LOG_UNINSTALL_UNATTENDED
191 !define UnLog_Uninstall_CallBackFunc "un._LocateCallBack_Function_Unattended"
198 !macro UNINSTALL.LOG_UNINSTALL_UNATTENDED
200 Function un._LocateCallBack_Function_Unattended
202 FileRead $unlog_tmp_2 "$unlog_tmp_3" ${NSIS_MAX_STRLEN}
203 ${un.TrimNewLines} "$unlog_tmp_3" "$unlog_tmp_3"
204 StrCmp "$unlog_tmp_3" "$R9" islog
209 IfFileExists "$R9\*.*" isdir
217 IntOp $unlog_tmp_1 $unlog_tmp_1 + 1
222 StrCmp "$R9" "${UNINST_EXE}" isfile
223 StrCmp "$R9" "${UNINST_DAT}" isfile
226 FileSeek $unlog_tmp_2 0 SET
233 !macro UNINSTALL.LOG_UNINSTALL_INTERACTIVE
235 Function un._LocateCallBack_Function_Interactive
237 FileRead $unlog_tmp_2 "$unlog_tmp_3" ${NSIS_MAX_STRLEN}
238 ${un.TrimNewLines} "$unlog_tmp_3" "$unlog_tmp_3"
239 StrCmp "$unlog_tmp_3" "$R9" islog
244 IfFileExists "$R9\*.*" isdir
252 IntOp $unlog_tmp_1 $unlog_tmp_1 + 1
257 FileSeek $unlog_tmp_4 0 SET
259 FileRead $unlog_tmp_4 "$unlog_tmp_3"
260 ${un.TrimNewLines} "$unlog_tmp_3" "$unlog_tmp_3"
261 StrCmp "$unlog_tmp_3" "$R9" end
265 StrCmp "$R9" "${UNINST_EXE}" isfile
266 StrCmp "$R9" "${UNINST_DAT}" isfile
267 IfFileExists "$R9\*.*" msgdir
269 MessageBox MB_ICONQUESTION|MB_YESNO \
270 'Delete File "$R9"?' /SD IDNO IDYES isfile IDNO nodel
273 MessageBox MB_ICONQUESTION|MB_YESNO \
274 'Delete Directory "$R9"?' /SD IDNO IDYES isdir IDNO nodel
277 FileSeek $unlog_tmp_4 0 END
278 FileWrite $unlog_tmp_4 "$R9$\r$\n"
281 FileSeek $unlog_tmp_2 0 SET
287 ;................................. Installer Macros .................................
289 !macro UNINSTALL.LOG_INSTALL_UNATTENDED
291 Function _LocateCallBack_Function_Install
293 FileRead $unlog_tmp_2 "$unlog_tmp_3" ${NSIS_MAX_STRLEN}
294 ${TrimNewLines} "$unlog_tmp_3" "$unlog_tmp_3"
297 FileSeek $unlog_tmp_2 0 SET
299 StrCmp "$R9" "$unlog_tmp_3" end
302 FileWrite $unlog_tmp_1 "$R9$\r$\n"
310 !ifdef UnLog_Install_Func_CallBack
311 !undef UnLog_Install_Func_CallBack
314 !ifndef UnLog_Install_Func_CallBack
315 !insertmacro UNINSTALL.LOG_INSTALL_UNATTENDED
316 !define UnLog_Install_Func_CallBack "_LocateCallBack_Function_Install"
320 !macro UNINSTALL.LOG_PREPARE_INSTALL
322 !verbose ${UNINST_LOG_VERBOSE}
327 ReadRegStr "$0" ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "${UNINSTALL_LOG}Directory"
330 StrCmp "$1" "-1" next
332 IfFileExists "$0\${UNINSTALL_LOG}.dat" next
333 MessageBox MB_ICONEXCLAMATION|MB_OK \
334 "Previous installation detected at $0.$\n\
335 Required file ${UNINSTALL_LOG}.dat is missing.$\n$\nIt is highly recommended \
336 to select an empty directory and perform a fresh installation." /SD IDOK
337 StrCpy $unlog_error "error"
341 StrCmp "$PLUGINSDIR" "" 0 +2
346 FileWrite $0 "${UNLOG_HEAD}$\r$\n"
348 Rename "$1" "${UNLOG_TEMP}"
356 !macro UNINSTALL.LOG_UPDATE_INSTALL
358 !verbose ${UNINST_LOG_VERBOSE}
360 Delete "${UNINST_DAT}"
361 Rename "${UNLOG_TEMP}" "${UNINST_DAT}"
362 WriteUninstaller "${UNINST_EXE}"
363 WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "${UNINSTALL_LOG}.dat" "${UNINST_DAT}"
364 WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "${UNINSTALL_LOG}Directory" "$INSTDIR"
370 !define uninstall.log_install "!insertmacro UNINSTALL.LOG_INSTALL"
372 !macro UNINSTALL.LOG_INSTALL FileOpenWrite FileOpenRead TargetDir
374 !verbose ${UNINST_LOG_VERBOSE}
376 FileOpen $unlog_tmp_1 "${FileOpenWrite}" w
377 FileOpen $unlog_tmp_2 "${FileOpenRead}" r
379 ${Locate} "${TargetDir}" "/L=FD" "${UnLog_Install_Func_CallBack}"
381 StrCmp $unlog_error "error" 0 +2
385 MessageBox MB_ICONEXCLAMATION|MB_OK "Error creating ${UNINSTALL_LOG} Log." /SD IDOK
387 FileClose $unlog_tmp_1
388 FileClose $unlog_tmp_2
394 !define uninstall.log_mergeID "!insertmacro UNINSTALL.LOG_MERGE"
396 !macro UNINSTALL.LOG_MERGE UnlogPart
398 !verbose ${UNINST_LOG_VERBOSE}
400 ${FileJoin} "${UNLOG_TEMP}" "${UnlogPart}" "${UNLOG_TEMP}"
406 !macro UNINSTALL.LOG_OPEN_INSTALL
408 !verbose ${UNINST_LOG_VERBOSE}
410 StrCmp $unlog_error "error" +2
411 ${uninstall.log_install} "${EXCLU_LIST}" "${UNINST_DAT}" "$OUTDIR"
417 !macro UNINSTALL.LOG_CLOSE_INSTALL
419 !verbose ${UNINST_LOG_VERBOSE}
421 !define ID ${__LINE__}
423 ${uninstall.log_install} "${UNLOG_PART}${ID}" "${EXCLU_LIST}" "$OUTDIR"
424 ${uninstall.log_mergeID} "${UNLOG_PART}${ID}"
434 ;_____________________________ HEADER FILE END ____________________________