Archive: Bug in 2.08: uninstaller wont delete folder


Bug in 2.08: uninstaller wont delete folder
its a reproduceable fault here - nsis 2.08 uninstaller wont delete $instdir - nsis 2.07 does.

its not fault of my script - i swapped versions w/o change.

the uninstaller demands a reboot although the folder is empty and not in use.

please have a look on it.

im back on 2.07 so long


Right before you call 'Delete $Instdir' call this command:

setoutpath "$Instdir"
setoutpath "..\" (you could try without the backslash)

This changes the current directory to the directory before it (ex. from C:\windows to C:\ . This means C:\windows can be deleted (Do not delete C:\windows - this just an example)). This means $Instdir can be deleted.

Hope this helps.


Right, haven't thought of that aspect when I made the change. The working directory of the installer is $INSTDIR, which is why it can't be deleted without SetOutPath. Please open a bug report and I'll fix it over the weekend.


-I just came here for this exact reason! Strange coinsidense...

Anyway - I installed version 2.08 tonight, and ran into the same problem.
Only I was not trying to remove the $INSTDIR, I was trying to remove a folder I had created just before in the installer. I used RMDir /r and Delete, but to no avail. I don't think this has been a problem before.

But it turned out that it was because the folder I had created and was now trying to delete, was the currently active folder just before the delete attempt (a SetOutPath "the folder I'm talking about" was before this in the script).

The installer successfully deleted all the files inside the folder, just not the folder itself.

However - when I now followed the advice given here, and put SetOutPath "..\" before the RMDir /r "folder in question" command, it worked, and the folder is now deleted. So thanks for the tip.

However, this isn't how it's supposed to work, is it? I don't think it was like that in the earlier versions.


Maybe RMDir itself should be changed so that it will go out of the folder in case the current folder has to be deleted. That would solve all issues.


Yes, Kichik wants to fix it over the weekend, I'm sure he will find a nice implementation, watch the CVS ;)


Fixed.


I would also like the ability to delete folders in the $INSTDIR path, example: if the $instdir is 'C:\jason\software\items', I would like to be able to delete the 'C:\jason\software' folder as well. Thinking of using setoutpath to do this but I haven't tried it yet.


Well, ofcourse this is possible as before. Not really related to de bug as described before. As long as you keep track in your script where you install all yourr software this will work out. For now, better save than sorry, use "..\" etc.

See manual and look at example:

...
;only deletes if there are no more applications files
RMDir /REBOOTOK "$PROGRAMFILES\${CompanyRootFolder}"
...


I have written some macros to work around the bug and to add another useful feature:

Think about a standard installer for "mysoftware".
If the user installs into "c:\program files\tools\mysoftware" in general only "mysoftware" gets removed by the uninstaller, regardless whether "tools" or "tools\mysoftware" already exist.

The macros at http://nsis.sourceforge.net/wiki/Dyn...ve_directories will give you the part of the path which already existed, so you can just remove the parts created.

Installer code:


!insertmacro MakeDirBase $INSTDIR
Pop $0
WriteRegStr HKLM "...your_regkey_path..." "BasePath" "$0"


Uninstaller code:


ReadRegStr $0 HKLM "...your_regkey_path..." "BasePath"
!insertmacro RemoveDirBase "$INSTDIR" $0


http://nsis.sourceforge.net/wiki/Dyn...ve_directories

well, your macros add lots of overhead to installers, if used multiple times.

you should rather stick to the common method used in several header files (like the WordFunc, FileFunc and TextFunc headers) where the features itself stay in Functions, and macros are only used to call them with one line.

this will greatly decrease the overhead, and also work around the need of Index_... defines.


Hi, I also have the same problem.. where do I place the new main.c.patch.txt file?


It's a part of the source code. For a compiled version grab the nightly build at http://nsis.sf.net