有没有办法使用 NSIS 从安装目录中保留 'uninstall.exe'(防止手动删除文件)

Is there a way to preserve the 'uninstall.exe' (prevent deletion of the file manually) from the install directory using NSIS

当用户从 Program Files 文件夹中手动删除 Uninstall.exe 文件时。然后从程序和功能中,如果用户试图卸载,应用程序将从程序和功能中删除。但是包含文件和注册表项的已安装文件夹仍然存在。

那么,是否有任何选项可以隐藏文件 (uninstall.exe) 或设置权限以防止手动删除此文件?

是也不是。

您可以将其设为隐藏文件,理论上您可以将 ACL 设置为拒绝删除(卸载程序本身必须再次编辑 ACL 才能删除它)但是没有什么可以阻止管理员删除如果他们真的想要一个文件。

Section
SetOutPath "$InstDir"
WriteUninstaller "$InstDir\un.exe"
SetFileAttributes "$InstDir\un.exe" HIDDEN
SectionEnd

Section Uninstall
Delete "$InstDir\un.exe"
RMDir "$InstDir"
SectionEnd