chasetoys
4th May 2006 09:23 UTC
recursively delete all folders/files within my app's direcotory
I dynamically create folders and directories within my applciation's program file directory.l.
I'm using the automatic NSIS script, but as far as I know, it only deletes the directories which exist upon installation.
So if I dynamially create files & files & direcotries, how can I can ensure that these files/fodlers are deleted as well?
Thanks!
Afrow UK
4th May 2006 09:41 UTC
If you want to delete the entire $INSTDIR, use RMDir /r $INSTDIR. The /r switch makes it recursive. However, this is generally a very bad idea as the user may install to the desktop or some other folder, and those files will be deleted as well.
-Stu
Red Wine
4th May 2006 09:59 UTC
probably this thread has info of what you're looking, you may change the given example to remove directories as well :-)
chasetoys
5th May 2006 23:22 UTC
followup
If I force the user to install in the Program Files\MyApp directory (and not allow them to change the install directory upon installation), and I use the recursive call to delete all files from the $INSTDIR, wouldn't this be AOK?
Afrow UK
6th May 2006 10:34 UTC
Yes. Perhaps you should have a MessageBox in your uninstaller though:
LangString ConfirmUninstall ${LANG_ENGLISH} "All existing \
files and folders under the $(^Name) installation directory \
will be removed.$\r$\nThis includes any files and folders \
that have since been added after the installation of \
$(^Name).$\r$\n$\r$\nAre you sure you wish to continue?"
...
MessageBox MB_OKCANCEL|MB_ICONINFORMATION $(ConfirmUninstall) IDOK +2
Abort
StrCpy $INSTDIR "$PROGRAMFILES\MyApp"
RMDir /r $INSTDIR
-Stu