Uninstall Software, NirSoft UninstallView

# Determine the UninstallView download URL based on system architecture
if ([Environment]::Is64BitOperatingSystem) {
    $DownloadUrl = "https://www.nirsoft.net/utils/uninstallview-x64.zip"
} else {
    $DownloadUrl = "https://www.nirsoft.net/utils/uninstallview.zip"
}

$DestinationFolder = "$env:SystemDrive\limehawk\nirsoft"

# Create the destination folder if it doesn't exist
if (-not (Test-Path $DestinationFolder)) {
    New-Item -ItemType Directory -Path $DestinationFolder | Out-Null
}

# Download and extract the UninstallView zip file
$ZipFilePath = Join-Path $DestinationFolder "UninstallView.zip"
Write-Host "Downloading $DownloadUrl to $ZipFilePath..."
Invoke-WebRequest -Uri $DownloadUrl -OutFile $ZipFilePath -UseBasicParsing

Write-Host "Extracting $ZipFilePath to $DestinationFolder..."
Expand-Archive -Path $ZipFilePath -DestinationPath $DestinationFolder -Force

# Uninstall the specified software using UninstallView
$UninstallProgram = "$appName*"
$UninstallViewPath = Join-Path $DestinationFolder "UninstallView.exe"

# Attempt to uninstall
Write-Host "Attempting to uninstall $appName..."
Start-Process -FilePath $UninstallViewPath -ArgumentList "/quninstallwildcard `"$UninstallProgram`" 5" -PassThru

Write-Host "Uninstall attempt completed for $appName. Please check manually to confirm uninstallation."

# Clean up by removing the downloaded zip file
Remove-Item $ZipFilePath -Force

Script data

Language - PowerShell

Run as - System / Root User

Script timeout duration - 5 Mins

Script variables

Run time variables

appName