NSIS Setup - How to install, uninstall, and log silently

This is the 3rd of my Packager-Specific Tips & Tricks articles.
Nullsoft Scriptable Install System (NSIS) is a free installer by Nullsoft, the creators of Winamp.
It creates self-contained EXE packages.

NSIS Setup INSTALL EXAMPLES

#Identification: Use 7Zip to inspect the EXE and look for many filenames starting with NS or NSIS
#NOTE: NSIS does not offer logging by default and Authors must do additional work add it. 
#	After 20+ years, I have never seen an NSIS package with logging yet.
Execute-Process -Path 'Setup.exe' -Parameters "/S"

.
NSIS Setup UNINSTALL EXAMPLES

Uninstall using Uninstall EXE in \ProgramFiles\

#NOTE: NSIS does not offer logging by default and Authors must do additional work add it. 
[String]$AppExePath = "C:\Program Files\Winamp\Uninstall.exe"
[String]$AppExeArgs = "/allusers /S"
Execute-Process -Path $AppExePath -Parameters $AppExeArgs -ContinueOnError $False

Uninstall using Uninstall EXE with fault tolerance

#If the Uninstall EXE is deleted from the C: drive, you cannot uninstall
#Here we copy the Uninstall EXE to $dirSupportFiles and use it as a last resort. Other files might be needed, too.
[String]$AppExePath	= "C:\Program Files\Winamp\Uninstall.exe"
[String]$AppExePathBak = "$dirSupportFiles\Uninstall.exe"
[String]$AppExeArgs	= "/allusers /S"
If (Test-Path $AppExePath) {
	Execute-Process -Path $AppExePath -Parameters $AppExeArgs -ContinueOnError $False
} Else {
	Write-log "EXE in C:\Program Files missing. Using backup copy" -Severity 2
	Execute-Process -Path $AppExePathBak -Parameters $AppExeArgs -ContinueOnError $False
}
2 Likes

Thank you so much for sharing this with the community, it is much appreciated. I did already a similar collection of those tips and tricks long time ago for myself, but it was not so comprehensive like yours!

1 Like