Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Removing parent directories (http://forums.winamp.com/showthread.php?t=125798)

tderouin 20th February 2003 20:58

Removing parent directories
 
Our current installation installs our product to something like:

C:\Program Files\CompanyName\ProductName

During the uninstall,
PHP Code:

  RMDir /"$INSTDIR

will only remove the ProductName folder, leaving an empty CompanyName folder.

Is there a smart way to remove the folder CompanyName? As far as I can tell there is no way to capture which directories are being created by the installer. Hardcoding
PHP Code:

  RMDir /"$INSTDIR"
  
RMDir /"C:\\Program Files\\CompanyName" 

isn't a viable solution, because the problem still exists for non-default installations that have subfolders (and this problem also exists for removing shortcuts).

Also, doing something like
PHP Code:

StrCpy $R0 $INSTDIR
loop
:
      
RMDir "$R0"
      
IfErrors goto done
      StrCpy 
"$R0" "$R0\\.."
      
goto loop
done


isn't a (completely) viable solution because you might end up deleting an empty directory the installer didn't create, that the user doesn't want deleted.

Suggestions?

rainwater 20th February 2003 21:03

http://nsis.sourceforge.net/archive/...instances=0,11

kichik 20th February 2003 21:23

You can use GetParent from the useful functions appendix (or from the link rainwater posted), use it on $INSTDIR and if what comes out is $PROGRAMFILES\CompanyName then you can delete it. I suggest you don't use /r so whatever the user put in there will stay.

tderouin 20th February 2003 21:55

Right, but that is pretty much the same thing as the RMDIR $R0\.. option.

What I need to know is whether or not the parent was created by the installer, what would be usefull (a suggestion) is that NSIS somehow keeps track of the files/directories it created, so they can be removed during the uninstall. I'm certain this is how most installers/uninstallers handle it.

kichik 20th February 2003 22:03

That's not the same as $R0\.. because you check against $PROGRAMFILES\CompanyName. If you want to know exactly which directories were created you can make a little recursion that will take the directory path apart and try to create every directory from the smallest part to the largest and final part. Use the latest CVS version and IfErrors after you create the directory to know if it was created or not. Save that somewhere and delete it upon uninstallation.

tderouin 20th February 2003 22:06

Right, but comparing it against CompanyName won't work if the user has entered in anoter value for "CompanyName". Right?

That's a good suggestion about creating the directories manually. Thanks :)


All times are GMT. The time now is 17:48.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.