NSIS Uninstaller Data: Difference between revisions
Liteshield (talk | contribs) mNo edit summary |
Liteshield (talk | contribs) m (Liteshield moved page NSIS Uninstaller Data - uninstall only installed files to Uninstaller Data - uninstall only installed files) |
Revision as of 21:21, 13 July 2014
Author: Liteshield (talk, contrib) |
Download
- Main download link: UnInst.nsh (7 KB).
- Mirror download link: UnInst.nsh.
Overview
It's been discussed fairly enough that the File /r command is very useful in cases when developers want to add a huge amount of sub directories and files, nevertheless it has the disadvantage that such an installation should be uninstalled with RmDir /r which is risky and removes also data that has been added/created before or later within the installation folder. Therefore Uninstaller Data has been madded to removes only files that have been installed.
Features
- Creates uninstall files list and can uninstall only installed files
- Supports different uninstall list names, that is useful while installing to the same folder or some components separately
- Skip uninstall of separated components if uninstall list does not exist
- Supports update of uninstall list when using the same list name
- Supports Interactive mode, what will require confirmation to remove every other file except those files that have been installed
- Supports Localization
- Minimal macros in script (only need 3)
About
Uninstaller Data is a macro system provided in a NSIS header that creates
temporary exclude list of current files and checks for new files after
installation to add them to the uninstall list.
Optionally it can interact with user during the uninstall process for every
other file found in installation folder and requires permission to remove it.
Also you can specify the terminate switch that will terminate the uninstaller
if the uninstall list has not been found.
Disadvantage
If the installation process will be not successfully the uninstall list will
not contain new created files during that installation.
If some other files during installation process will be added to a destination
folder they will be also included to the uninstall list.
If uninstall list file is missing, uninstaller won't be able to uninstall files.
Therefore sometimes it's better to use Uninstall Header Recursive File List Maker.
License
This header file is provided 'as-is', without any express or implied
warranty.
In no event will the author be held liable for any damages
arising from the use of this header file.
Permission is granted to anyone to use this header file for any purpose,
including commercial applications,
and to alter it and redistribute
it freely, subject to the following restrictions:
- The origin of this header file must not be misrepresented; you must not claim that you wrote the original header file.
- If you use this header file in a product, an acknowledgment in the product documentation would be appreciated but is not required.
- Altered versions must be plainly marked as such, and must not be misrepresented as being the original header file.
- This notice may not be removed or altered from any distribution.
How to use
Add the include to the top of your script
!include "UnInst.nsh" ;Define uninstall list name (optimal) !define UninstName "Uninstall" ;Localize (optimal) !define UNINST_DAT_NOT_FOUND "$UNINST_DAT not found, unable to perform uninstall. Manually delete files." !define UNINST_DAT_MISSING "$UNINST_DAT is missing, some elements could not be removed. These can be removed manually. " !define UNINST_DEL_FILE "Delete File" Section "Section Name" Sec1 SetOutPath "$INSTDIR" ;Create exclude list !insertmacro UNINST_EXCLUDE ;Install files File /r App\*.* ;This will redefine ${UninstName} (optimal) !insertmacro UNINST_NAME "unins000" ;Store uninstall data !insertmacro UNINST_DATA ;Create uninstaller WriteUninstaller "$OUTDIR\${UninstName}.exe" SectionEnd Section "Uninstall" ;Require confirmation to delete every other file except installed (optimal) !define UNINST_INTERACTIVE ;Terminate uninstaller if the .dat file does not exist (optimal) !define UNINST_TERMINATE ;Delete files !insertmacro UNINST_DELETE "$INSTDIR" "${UninstName}" ;Remove installation folder if it is empty RMDir "$INSTDIR" SectionEnd