NSIS Uninstaller Data: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
mNo edit summary
mNo edit summary
 
(6 intermediate revisions by the same user not shown)
Line 2: Line 2:


== Download ==
== Download ==
* Main download link: <attach>UnInst.zip</attach>.
 
* Mirror download link: [http://yadi.sk/d/4tZFXsk-SPZ3K UnInst.zip].
* Main download link: <attach>UnInst.nsh</attach>
* Mirror download link: [https://yadi.sk/d/lzv8UMIYZM8LS UnInst.nsh]


== Overview ==
== Overview ==
It's been discussed fairly enough that the File /r command is very useful
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
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
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
be uninstalled with RmDir /r which is risky and removes also data that has
been added/created before or later within the installation folder.<br>
been added/created before or later within the installation folder. Therefore
Therefore NSIS Uninstaller Data has been madded to removes only files that  
Uninstaller Data has been madded to removes only files that have been installed.
have been installed.<br>
 
== 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 ==
== About ==
NSIS Uninstaller Data is a macro system provided in a NSIS header that
 
creates temporary exclude list of current files and checks for new files
Uninstaller Data is a macro system provided in a NSIS header that creates
after installation to add them to the uninstall list.<br>
temporary exclude list of current files and checks for new files after
installation to add them to the uninstall list.<br>
Optionally it can interact with user during the uninstall process for every
Optionally it can interact with user during the uninstall process for every
other file found in installation folder and requires permission to remove it.  
other file found in installation folder and requires permission to remove it.  
Also you can specify the terminate switch that will terminate the uninstaller
Also you can specify the terminate switch that will terminate the uninstaller
if the uninstall list has not been found.<br>
if the uninstall list has not been found.


== Disadvantage ==
== Disadvantage ==
If the installation process will be not successfully the uninstall list will
If the installation process will be not successfully the uninstall list will
not contain new created files during that installation.<br>
not contain new created files during that installation.<br>
If some other files during installation process will be added to a destination
If some other files during installation process will be added to a destination
folder they will be also included to the uninstall list.<br>
folder they will be also included to the uninstall list.<br>
If uninstall list file is missing uninstaller won't be able to uninstall files.<br>
If uninstall list file is missing, uninstaller won't be able to uninstall files.  
 
Therefore sometimes it's better to use [http://nsis.sourceforge.net/Uninstall_Header_Recursive_File_List_Maker Uninstall Header Recursive File List Maker].
== Features ==
 
* Creates uninstall files list and can uninstall only installed files<br>
 
* Supports different uninstall list names, that is useful while installing to the same folder or some componets separately<br>
 
* Skip uninstall of separated componets if uninstall list does not exist<br>
 
* Supports update of uninstall list when using the same list name<br>
 
* Supports Interactive uninstaller mode, what will require confirmation to remove every other file exept those files that have been installed<br>
 
* Supports Localization<br>
 
* Minimal macros in script (only need 3)<br>


== License ==
== License ==
Line 57: Line 55:


*The origin of this header file must not be misrepresented; you must not claim that you wrote the original header file.  
*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.
*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.
*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.
*This notice may not be removed or altered from any distribution.


Line 76: 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
!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"
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 84: Line 88:
   SetOutPath "$INSTDIR"
   SetOutPath "$INSTDIR"


   ;Create exclude list
   ;Create an exclusion list
   !insertmacro UNINST_EXCLUDE
   !insertmacro UNINSTALLER_DATA_BEGIN


   ;Install files
   ;Add/Install Files
   File /r App\*.*
   File /r App\*.*


   ;This will redefine ${UninstName} (optimal)
   ;Change uninstall list name (optimal)
   !insertmacro UNINST_NAME "unins000"
   !insertmacro UNINST_NAME "unins000"


   ;Store uninstall data
   ;Store uninstaller data
   !insertmacro UNINST_DATA
   !insertmacro UNINSTALLER_DATA_END


   ;Create uninstaller
   ;Create uninstaller

Latest revision as of 21:25, 9 August 2014

Author: Liteshield (talk, contrib)


Download

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