如何删除使用 * 创建的文件

How to delete files created with *

我正在使用 NSIS 创建一个安装程序,它将安装 100 多个文件。

我知道要指定要安装的文件,您可以使用

File /r ..\release\*

效果很好。

但是我应该如何卸载这些文件(除了对我知道已安装的每个文件单独使用删除命令。)

我查看了 RMDir,它似乎不太安全。还有 here 没用。

感谢您的宝贵时间

RMDir 是安全的。它使用了文档警告的 /r 标志:

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. The user can also put other files but the program's files and would expect them to get deleted with the program. Solutions are available for easily uninstalling only files which were installed by the installer

鉴于此,我认为您只需手动删除所有子目录,然后删除父目录。我能想到的唯一一种不起作用的情况是当您的应用程序动态生成新文件夹时。如果是这种情况,即使是卸载日志也无济于事。

在您创建的子目录上使用 /r 也完全可以。问题是删除了顶级安装目录,以及其中可能存在的所有内容。如果您的安装程序推出了一个包含名为 images 的附加资产的文件夹,其中还包含子目录,则没有理由

RMDir /r $INSTDIR\images`

会很危险。