Urd
11th December 2004 15:48 UTC
Uninstaller based on installed components
Is it possible to write an uninstaller that will delete only components selected when installing without having to make a components page on the uninstaller and without deleting any default files? This installer will replace files already on the PC with new ones and rename the old ones. The uninstaller as it is now will delete the new files and rename the old ones back. The problem is if only one of the new files is installed to replace a default one the uninstaller will delete and rename the first file and delete the second witohut it having a file to rename in its place.
Afrow UK
11th December 2004 15:54 UTC
This should help:
http://forums.winamp.com/showthread....hreadid=199750
Basically you need to create a list of files being installed, and read from this list on uninstall.
-Stu
Urd
12th December 2004 02:54 UTC
Ok i used that script at the link and the file path is written into the uninstall.log but when I run the uninstaller it doesn't delete the file.
Function un.Rename
Rename $INSTDIR\userconfig.cfg.old $INSTDIR\userconfig.cfg
FunctionEnd
Section Uninstall
; Can't uninstall if uninstall.log is missing!
IfFileExists "$INSTDIR\uninstall.log" +3
MessageBox MB_OK|MB_ICONSTOP "uninstall.log not found!$\r$\nUninstallation cannot be done!"
Abort
Push $R0
FileOpen $UninstLog "$INSTDIR\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
Call un.inst
SectionEnd
function un.inst
Delete "$INSTDIR\Uninstall.exe"
Delete "$INSTDIR\Uninstall.log"
Call un.rename
FunctionEnd
Function un.TrimNewlines
Exch $R0
Push $R1
Push $R2
StrCpy $R1 0
loop:
IntOp $R1 $R1 - 1
StrCpy $R2 $R0 1 $R1
StrCmp $R2 "$\r" loop
StrCmp $R2 "$\n" loop
IntOp $R1 $R1 + 1
IntCmp $R1 0 no_trim_needed
StrCpy $R0 $R0 $R1
no_trim_needed:
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
That is the code im using for the uninstaller and this is what is in the log file:
c:\steam\steamapps\etc3313@hotmail.com\Counter-Strike\userconfig.cfg
But it doesn't uninstall that file.
Afrow UK
12th December 2004 14:53 UTC
Are you sure that's not because you have just renamed it back?
What you need is:
Section Uninstall
; Can't uninstall if uninstall.log is missing!
IfFileExists "$INSTDIR\uninstall.log" +3
MessageBox MB_OK|MB_ICONSTOP "uninstall.log not found!$\r$\nUninstallation cannot be done!"
Abort
Push $R0
FileOpen $UninstLog "$INSTDIR\uninstall.log" r
LoopRead:
ClearErrors
FileRead $UninstLog $R0
IfErrors LoopDone
Push $R0
Call un.TrimNewLines
Pop $R0
Delete $R0
Rename $R0.old $R0
Goto LoopRead
LoopDone:
FileClose $UninstLog
Pop $R0
SectionEnd
There's no need for the seperate rename function.
-Stu
Urd
12th December 2004 18:40 UTC
Adding in Rename $R0.old $R0 didn't work.
Urd
12th December 2004 18:45 UTC
Nm I found the problem, the file path is missing a part.
Afrow UK
12th December 2004 18:49 UTC
Make sure $R0.old is there already!
Obviously $R0.old should have existed before hand (from using Rename in your install Section)
In your install section you'd need something like this:
Section "Install new user-config"
SetOutPath $INSTDIR
IfFileExists "$INSTDIR\userconfig.cfg" 0 +2
Rename "$INSTDIR\userconfig.cfg" "$INSTDIR\userconfig.cfg.old"
${File} "userconfig.cfg"
SectionEnd
-Stu