Uninstall only installed files: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Updated by user: Afrow UK.) |
m (Updated author and download links, and changed format of some pages.) |
||
Line 69: | Line 69: | ||
-Stu | -Stu | ||
Page author: Afrow UK | Page author: [[User:Afrow UK|Afrow UK]] |
Revision as of 12:45, 23 April 2005
Description
This a code written in the NSIS forums for Rookie12 a long while back. So many people have asked the same question since, so I thought that it was a good idea to put it up on here. You need the TrimNewLines function present in your script also. Make sure you rename the TrimNewLines function name to un.TrimNewLines (as the function is used in the uninstaller, ala "un.").
The Script
Var UninstLog ; Add file macro !macro File FileName File "${FileName}" FileWrite $UninstLog "$OUTDIR\${FileName}$\r$\n" !macroend !define File "!insertmacro File" Section -openlogfile FileOpen $UninstLog "$INSTDIR\uninstall.log" w SectionEnd Section "Install Main" SetOutPath $INSTDIR ${File} "file1.ext" ${File} "file2.ext" ${File} "file3.ext" SectionEnd Section "Install Other" SetOutPath "$INSTDIR\Other" ${File} "file4.ext" ${File} "file5.ext" ${File} "file6.ext" SectionEnd Section -closelogfile FileClose $UninstLog SectionEnd Section Uninstall ; Can't uninstall if uninstall.log is missing! IfFileExists "$EXEDIR\uninstall.log" +3 MessageBox MB_OK|MB_ICONSTOP "uninstall.log not found!$\r$\n \ Uninstallation cannot proceed!" Abort Push $R0 FileOpen $UninstLog "$EXEDIR\uninstall.log" r LoopRead: ClearErrors FileRead $UninstLog $R0 IfErrors LoopDone Push $R0 Call un.TrimNewLines Pop $R0 Delete $R0 Goto LoopRead LoopDone: FileClose $UninstLog Pop $R0 SectionEnd
-Stu
Page author: Afrow UK