Crew Two

Notepad++ Universal Uninstaller

Notepad++ is a text editor and source code editor for use with Microsoft Windows. The vendor installer is an executable file with silent switch.

PowerShell logging is turned on and will write to %ProgramData%\Software.

Removes any version of Notepad++, whether 32 or 64-bit. A variable array is used to ensure both Program Files locations are checked.

Uninstall.ps1

# This script performs the installation or uninstallation of an application(s).
# Created 29/07/2019 | cru2.io

# Variables
[string]$CurrentPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
[string]$appLogPath = "$env:ProgramData\Software"
If (!(Test-Path $appLogPath))
	{New-Item -ItemType Directory $appLogPath -Force -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null}

Start-Transcript -Path "$appLogPath\Notepad++ Universal Uninstaller.log" -Append

# Remove previous versions if exist
Write-Host "Check for and uninstall previous versions of Notepad++ (32 or 64-bit)"
[array]$appFolders = ${env:ProgramFiles(x86)},$env:ProgramFiles
ForEach ($appFolder in $appFolders)
	{
	$appPath = $appFolder + '\Notepad++'
	If (Test-Path "$appPath\notepad++.exe")
		{
		$OldVersion = (Get-Item "$appPath\notepad++.exe").VersionInfo.FileVersion
		}
	
	If (Test-Path "$appPath\uninstall.exe")
		{
		Write-Host "Uninstalling Notepad++ $OldVersion"
		Start-Process "$appPath\uninstall.exe" -ArgumentList "/S" -Wait -PassThru -NoNewWindow -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null
		Sleep 5
		Remove-Item $appPath -Recurse -Force -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null
		}
	}

Stop-Transcript | Out-Null

About: nick