NSIS Uninstaller Data: Difference between revisions
Liteshield (talk | contribs) m (Liteshield moved page Uninstaller Data - uninstall only installed files to NSIS Uninstaller Data) |
Liteshield (talk | contribs) mNo edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
== Download == | == Download == | ||
* Main download link: <attach>UnInst.nsh</attach> | * Main download link: <attach>UnInst.nsh</attach> | ||
* Mirror download link: [https://yadi.sk/d/ | * Mirror download link: [https://yadi.sk/d/lzv8UMIYZM8LS UnInst.nsh] | ||
== Overview == | == Overview == | ||
Line 17: | Line 17: | ||
== Features == | == Features == | ||
* Creates | * Creates uninstaller files list and can uninstall only installed files | ||
* Supports different uninstall list names, | * Supports different uninstall list names, what is useful while installing to the same folder or some components separately | ||
* Skip uninstall of separated components if uninstall list does not exist | * Skip uninstall of separated components if uninstall list does not exist | ||
* Supports update of uninstall list when using the same list name | * Supports update of uninstall list when using the same list name | ||
Line 71: | Line 71: | ||
;Localize (optimal) | ;Localize (optimal) | ||
!define UNINST_DAT_NOT_FOUND "$UNINST_DAT not found, unable to perform uninstall. Manually delete files." | !define UNINST_LOCALIZE | ||
LangString UNINST_EXCLUDE_ERROR ${LANG_ENGLISH} "Error creating an exclusion list." | |||
LangString UNINST_EXCLUDE_ERROR ${LANG_RUSSIAN} "Ошибка при создании списка исключений." | |||
LangString UNINST_DATA_ERROR ${LANG_ENGLISH} "Error creating the uninstaller data: $\r$\nCannot find an exclusion list." | |||
LangString UNINST_DATA_ERROR ${LANG_RUSSIAN} "Ошибка при создании данных деинсталлятора: $\r$\nНе удается найти список исключений." | |||
LangString UNINST_DAT_NOT_FOUND ${LANG_ENGLISH} "$UNINST_DAT not found, unable to perform uninstall. Manually delete files." | |||
LangString UNINST_DAT_NOT_FOUND ${LANG_RUSSIAN} "$UNINST_DAT не найден, не удается выполнить удаление. Удалите файлы вручную." | |||
LangString UNINST_DAT_MISSING ${LANG_ENGLISH} "$UNINST_DAT is missing, some elements could not be removed. These can be removed manually." | |||
LangString UNINST_DAT_MISSING ${LANG_RUSSIAN} "$UNINST_DAT отсутствует, некоторые элементы не могут быть удалены. Они могут быть удалены вручную." | |||
LangString UNINST_DEL_FILE ${LANG_ENGLISH} "Delete File" | |||
LangString UNINST_DEL_FILE ${LANG_RUSSIAN} "Удалить файл" | |||
Section "Section Name" Sec1 | Section "Section Name" Sec1 | ||
Line 79: | Line 88: | ||
SetOutPath "$INSTDIR" | SetOutPath "$INSTDIR" | ||
;Create | ;Create an exclusion list | ||
!insertmacro | !insertmacro UNINSTALLER_DATA_BEGIN | ||
;Install | ;Add/Install Files | ||
File /r App\*.* | File /r App\*.* | ||
; | ;Change uninstall list name (optimal) | ||
!insertmacro UNINST_NAME "unins000" | !insertmacro UNINST_NAME "unins000" | ||
;Store | ;Store uninstaller data | ||
!insertmacro | !insertmacro UNINSTALLER_DATA_END | ||
;Create uninstaller | ;Create uninstaller |
Latest revision as of 21:25, 9 August 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 uninstaller files list and can uninstall only installed files
- Supports different uninstall list names, what 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_LOCALIZE LangString UNINST_EXCLUDE_ERROR ${LANG_ENGLISH} "Error creating an exclusion list." LangString UNINST_EXCLUDE_ERROR ${LANG_RUSSIAN} "Ошибка при создании списка исключений." LangString UNINST_DATA_ERROR ${LANG_ENGLISH} "Error creating the uninstaller data: $\r$\nCannot find an exclusion list." LangString UNINST_DATA_ERROR ${LANG_RUSSIAN} "Ошибка при создании данных деинсталлятора: $\r$\nНе удается найти список исключений." LangString UNINST_DAT_NOT_FOUND ${LANG_ENGLISH} "$UNINST_DAT not found, unable to perform uninstall. Manually delete files." LangString UNINST_DAT_NOT_FOUND ${LANG_RUSSIAN} "$UNINST_DAT не найден, не удается выполнить удаление. Удалите файлы вручную." LangString UNINST_DAT_MISSING ${LANG_ENGLISH} "$UNINST_DAT is missing, some elements could not be removed. These can be removed manually." LangString UNINST_DAT_MISSING ${LANG_RUSSIAN} "$UNINST_DAT отсутствует, некоторые элементы не могут быть удалены. Они могут быть удалены вручную." LangString UNINST_DEL_FILE ${LANG_ENGLISH} "Delete File" LangString UNINST_DEL_FILE ${LANG_RUSSIAN} "Удалить файл" Section "Section Name" Sec1 SetOutPath "$INSTDIR" ;Create an exclusion list !insertmacro UNINSTALLER_DATA_BEGIN ;Add/Install Files File /r App\*.* ;Change uninstall list name (optimal) !insertmacro UNINST_NAME "unins000" ;Store uninstaller data !insertmacro UNINSTALLER_DATA_END ;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