- NSIS Discussion
- Unistaller code seems to not work
Archive: Unistaller code seems to not work
pet_Gr
1st March 2005 22:38 UTC
Unistaller code seems to not work
Hello i've write here my uninstaller section, but it seems that it's not working because it doesn't delete the directory neither the unistall program
Section "Uninstall"
Delete "$INSTDIR\Reports\Dba\*.*"
Delete "$INSTDIR\Reports\Objetos\*.*"
Delete "$INSTDIR\Reports\PLSQL\*.*"
Delete "$INSTDIR\Reports\Usuario\*.*"
Delete "$INSTDIR\Manual.pdf"
Delete "$INSTDIR\Manual.cnt"
Delete "$INSTDIR\Manual.hlp"
Delete "$INSTDIR\Manual.lang"
Delete "$INSTDIR\Manual.pdf"
Delete "$INSTDIR\Uninstall.exe"
Rmdir "$INSTDIR\Reports\Dba"
Rmdir "$INSTDIR\Reports\Objetos"
Rmdir "$INSTDIR\Reports\PLSQL"
Rmdir "$INSTDIR\Reports\Usuario"
Rmdir "$INSTDIR\Reports"
Rmdir "$INSTDIR"
SectionEnd
Can someone help me?
Yathosho
1st March 2005 23:42 UTC
uninstaller sections must begin with un. (i.e. Section "un.Uninstaller") as written in the manual. if RMDir still doesn't work then, use it with /REBOOTOK.
Pidgeot
2nd March 2005 00:12 UTC
No, that's just for sections beyond the first. If you only have one, the proper name is "Uninstall". See #4.6.2 in the manual.
As for getting the files deleted, you should (as said above) try using /REBOOTOK, in case some of the files are in use. Also be sure that your uninstaller is placed in the program directory, as that's where the uninstaller gets $INSTDIR from (also mentioned in #4.6.2). If it isn't, place it there or retrieve the value from somewhere, such as the registry.
Pet_gr
2nd March 2005 07:46 UTC
I'll try to test it, thanks to all in anyway you
Greetings
Pedro Garcia Rodriguez
pet_Gr
2nd March 2005 09:56 UTC
no work.what can i do the /rebootok don't delete the directory and don't delete the uninstall program
Afrow UK
2nd March 2005 14:19 UTC
Just do:
Rmdir /rebootok /r "$INSTDIR"
/r == recursive, so it'll delete the directory and all files in it (if it isn't empty).
-Stu
Pet_Gr
3rd March 2005 11:31 UTC
I used the instdir in this way
c:\bla bla bla\ ble ble ble
THe installer delete the ble ble ble but no the bla bla directory
anyone knows why?
Pidgeot
3rd March 2005 14:05 UTC
RMDir only removes the topmost directory specified, in this case "ble ble ble", regardless whether or not you specify recursive deletion. If you want to delete "bla bla bla" as well, you need to find uot what "bla bla bla" is and delete it with an additional RMDir.
Being able to delete "bla bla bla" with RMDir "C:\bla bla bla\ble ble ble" would be very insecure, as you may end up deleting something important.
Afrow UK
3rd March 2005 14:11 UTC
Ah right, this is a problem that has always existed.
I wrote this function quite a while ago which should work:
http://nsis.sourceforge.net/archive/...php?pageid=302
You pass it your $INSTDIR and then the number of parent folders to remove. It will remove the folders only if they are empty.
The top level folder ($INSTDIR) will be removed with /r switch so you do not need to use Rmdir /rebootok /r "$INSTDIR" anymore.
-Stu
Gato Muerto
29th April 2005 02:40 UTC
I've tried including the code, but it just doesn't seem to work. The code included is as follows:
Function un.UninstallDirs
Exch $R0 ;input string
Exch
Exch $R1 ;maximum number of dirs to check for
Push $R2
Push $R3
Push $R4
Push $R5
IfFileExists "$R0\*.*" 0 +2
RMDir /r "$R0"
StrCpy $R5 0
top:
StrCpy $R2 0
StrLen $R4 $R0
loop:
IntOp $R2 $R2 + 1
StrCpy $R3 $R0 1 -$R2
StrCmp $R2 $R4 exit
StrCmp $R3 "\" 0 loop
StrCpy $R0 $R0 -$R2
IfFileExists "$R0\*.*" 0 +2
RMDir "$R0"
IntOp $R5 $R5 + 1
StrCmp $R5 $R1 exit
Goto top
exit:
Pop $R5
Pop $R4
Pop $R3
Pop $R2
Pop $R1
Pop $R0
FunctionEnd
#location where code is called is elsewhere (uninstall section):
Section "Uninstall"
#Code clipped for brevity
RMDir /R "$INSTDIR"
Push 2
Push "$INSTDIR"
Call un.UninstallDirs
StrCpy $0 "%c"
CallInstDLL "$PLUGINSDIR\nsisdt.dll" currentdate
DetailPrint "Uninstallation finished $0."
Push "$TEMP\${PRODUCTNAME}-uninstall.log"
DetailPrint "Please wait while uninstaller finishes..."