NSIS Uninstaller Data: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(Created page with "{{PageAuthor|LiteShield}} == Links == ===== Download ===== * Main download link: <attach>UnInst.zip</attach>. * Mirror download link: [http://yadi.sk/d/4tZFXsk-SPZ3K UnInst.z...")
 
No edit summary
Line 115: Line 115:
   !insertmacro UNINST_DELETE "$INSTDIR" "${UninstName}"
   !insertmacro UNINST_DELETE "$INSTDIR" "${UninstName}"


   ;Remove installation folder
   ;Remove installation folder if it is empty
   RMDir "$INSTDIR"
   RMDir "$INSTDIR"



Revision as of 15:24, 5 June 2014

Author: LiteShield (talk, contrib)


Links

Download
  • Main download link: UnInst.zip not found.
  • Mirror download link: UnInst.zip.

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 NSIS Uninstaller Data has been madded to removes only files that have been installed.

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 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.

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 componets separately
  • Skip uninstall of separated componets if uninstall list does not exist
  • Supports update of uninstall list when using the same list name
  • Supports Interactive uninstaller mode, what will require confirmation
 to remove every other file exept those files that have been installed
  • Supports Localization
  • Minimal macros in script, only 3 are required to work

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