Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to do "RmDir /r $INSTDIR" in NSIS?

I noticed this warning in the documentation for NSIS's RmDir method:

Warning: using RMDir /r $INSTDIR in the uninstaller is not safe. Though it is unlikely, the user might select to install to the Program Files folder and so this command will wipe out the entire Program Files folder, including other programs that has nothing to do with the uninstaller.

This scares me, since up until now I had not considered this possibility and I had that exact line in my script. But when I tested if this would happen by installing my program to a pre-existing location containing pre-existing files and then running my uninstaller with RmDir /r /REBOOTOK $INSTDIR in it, the existing files were left unharmed.

Is this an outdated warning? I'm using NSIS v. 2.46.

Thanks

like image 243
Cuga Avatar asked Jul 15 '10 20:07

Cuga


2 Answers

RmDir /r will delete the whole directory tree if it can, so it is "unsafe". See http://nsis.sourceforge.net/Uninstall_only_installed_files for a way to only delete the files you install

like image 71
Anders Avatar answered Nov 12 '22 15:11

Anders


RMDir on a directory without /r (recursive) flag will remove the directory if it is empty. At some point they have added this feature, not sure when.

NSIS Scripting Reference - RMDir

like image 1
mcNux Avatar answered Nov 12 '22 14:11

mcNux