Uninstall Header Recursive File List Maker

From NSIS Wiki
Jump to navigationJump to search
Author: Liteshield (talk, contrib)


Download

Description

This batch files when executed recursively creates a list header for uninstallation.

Use

Save the created header to an include folder. Then !include UnFiles.nsh in Section "Uninstall" of your nsi script as follows:

Section "Uninstall"
 
  ;Use generated header to delete files
  !include "UnFiles.nsh"
 
  Delete "$INSTDIR\Uninstall.exe"
 
  SetOutPath "$INSTDIR\.."
  RMDir "$INSTDIR"
 
SectionEnd

UnFiles.cmd

UnFiles.cmd produces a list of files and folders to be deleted and adds the required nsi commands.

UNFILES.CMD "TargetFolder" ["OutputHeaderFile"]

You can also use another batch file to generate uninstall list for multiple folders:

Generate.bat

Generate.bat functions as a wrapper for UnFiles.cmd:

SET HEADER_FILE=UnFiles.nsh
DEL /Q %HEADER_FILE%
 
CALL UnFiles "Dir1" "%HEADER_FILE%"
CALL UnFiles "Dir2" "%HEADER_FILE%"