-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathUninstall-InnoSetup.ps1
More file actions
31 lines (27 loc) · 1.15 KB
/
Uninstall-InnoSetup.ps1
File metadata and controls
31 lines (27 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function Uninstall-InnoSetup {
<#
.SYNOPSIS
Uninstall Inno Installed Application
.DESCRIPTION
This function uninstalls an application that was installed using the Inno installer.
.PARAMETER AppName
Exact name as shown in Add/Remove Programs
#>
[CmdletBinding()]
param
(
[ValidateNotNullOrEmpty()][string]$AppName
)
$QuietUninstallString = ((Get-ChildItem -Path "REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\","REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" | ForEach-Object { Get-ItemProperty REGISTRY::$_ } | Where-Object { $_.DisplayName -eq $AppName }).QuietUninstallString).split("/")
$Switches = "/" + $QuietUninstallString[1].Trim()
Write-Host "Uninstall"$AppName"....." -NoNewline
$ErrCode = (Start-Process -FilePath $QuietUninstallString[0].Trim() -ArgumentList $Switches -Wait -Passthru).ExitCode
If (($ErrCode -eq 0) -or ($ErrCode -eq 3010)) {
Write-Host "Success" -ForegroundColor Yellow
} elseif ($ErrCode -eq 1605) {
Write-Host "Not Present" -ForegroundColor Green
} else {
Write-Host "Failed with Error Code:"$ErrCode
Exit $ErrCode
}
}