Uninstall only installed files: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (Wikipedia python library) |
m (Updated by user: Afrow UK.) |
||
Line 2: | Line 2: | ||
This a code written in the NSIS forums for [[user:Rookie12|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. | This a code written in the NSIS forums for [[user:Rookie12|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 [http://nsis.sourceforge.net/Docs/AppendixC.html#C.2 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."). | You need the [http://nsis.sourceforge.net/Docs/AppendixC.html#C.2 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 ==
<highlight-nsis> | == The Script == | ||
<highlight-nsis> | |||
Var UninstLog | Var UninstLog | ||
Line 42: | Line 43: | ||
; Can't uninstall if uninstall.log is missing! | ; Can't uninstall if uninstall.log is missing! | ||
IfFileExists "$EXEDIR\uninstall.log" +3 | IfFileExists "$EXEDIR\uninstall.log" +3 | ||
MessageBox MB_OK|MB_ICONSTOP "uninstall.log not found!$\r$\ | MessageBox MB_OK|MB_ICONSTOP "uninstall.log not found!$\r$\n \ | ||
Uninstallation cannot proceed!" | |||
Abort | Abort | ||
Revision as of 01:20, 13 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