Old 20th February 2003, 20:58   #1
tderouin
Member
 
Join Date: Jan 2003
Posts: 79
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?
tderouin is offline   Reply With Quote
Old 20th February 2003, 21:03   #2
rainwater
Senior Member
 
Join Date: Aug 2000
Posts: 397
Send a message via ICQ to rainwater
http://nsis.sourceforge.net/archive/...instances=0,11
rainwater is offline   Reply With Quote
Old 20th February 2003, 21:23   #3
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 20th February 2003, 21:55   #4
tderouin
Member
 
Join Date: Jan 2003
Posts: 79
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.
tderouin is offline   Reply With Quote
Old 20th February 2003, 22:03   #5
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 20th February 2003, 22:06   #6
tderouin
Member
 
Join Date: Jan 2003
Posts: 79
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
tderouin is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump