Skip to content

Commit ad55fac

Browse files
authored
Merge pull request #80 from mikeee/fix-msiafterburner
Fix msiafterburner uninstallation
2 parents fc057b6 + 2dfc34c commit ad55fac

File tree

4 files changed

+23
-44
lines changed

4 files changed

+23
-44
lines changed

automatic/msiafterburner/msiafterburner.nuspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ enclosed in quotation marks, you should use an editor that supports UTF-8, not t
7474
<!-- Specifying dependencies and version ranges?
7575
https://docs.nuget.org/create/versioning#specifying-version-ranges-in-.nuspec-files -->
7676
<dependencies>
77+
<dependency id="autohotkey.portable" version="1.1.30.03" />
7778
<!-- <dependency id="autohotkey" /> -->
7879
<!-- <dependency id="" version="[__EXACT_VERSION__]" /> -->
7980
<!-- <dependency id="" version="[_MIN_VERSION_INCLUSIVE, MAX_VERSION_EXCLUSIVE)" /> -->

automatic/msiafterburner/tools/chocolateyInstall.ps1

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@ $checksumType = 'SHA256'
55
$unpackDir = $(Split-Path -parent $MyInvocation.MyCommand.Definition)
66
$unpackFile = Join-Path $unpackDir 'afterburner.zip'
77

8-
$toolsPath = Split-Path $MyInvocation.MyCommand.Definition
9-
. $toolsPath\helpers.ps1
8+
Get-Process -Name 'msi afterburner' -ErrorAction SilentlyContinue | Stop-Process
109

1110
Get-ChocolateyWebFile $packageName $unpackFile $url -Checksum $checksum -ChecksumType $checksumType
1211
Get-ChocolateyUnzip -fileFullPath $unpackFile -destination $unpackDir
1312
$file = (Get-ChildItem -Path $unpackDir -Recurse | Where-Object { $_.Name -match "^MSIAfterburnerSetup.*\.exe$" }).fullname
1413

15-
Stop-Afterburner
16-
1714
$packageArgs = @{
1815
PackageName = $packageName
1916
FileType = 'exe'
Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
1-
$packageName = 'msiafterburner'
2-
$installerType = 'exe'
1+
$ErrorActionPreference = 'Stop';
2+
3+
$packageName = $env:ChocolateyPackageName
4+
$software = @('MSI Afterburner*', 'RivaTuner Statistics Server*')
35
$silentArgs = '/S'
4-
$validExitCodes = @(0)
56
$scriptPath = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
67
$ahkFile = Join-Path $scriptPath 'chocolateyUninstall.ahk'
78
$ahkExe = 'AutoHotKey'
89
$ahkRun = "$Env:Temp\$(Get-Random).ahk"
9-
$packageSearchRegex = '^(MSI Afterburner|RivaTuner Statistics Server).*'
10-
11-
$toolsPath = Split-Path $MyInvocation.MyCommand.Definition
12-
. $toolsPath\helpers.ps1
13-
14-
Stop-Afterburner
1510

1611
Copy-Item $ahkFile "$ahkRun" -Force
1712
Start-Process $ahkExe $ahkRun
1813

19-
Get-ItemProperty `
20-
-Path @('HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*',
21-
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',
22-
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*') `
23-
-ErrorAction:SilentlyContinue `
24-
| Where-Object `
25-
{$_.DisplayName -Match $packageSearchRegex} `
26-
| ForEach-Object `
27-
{Uninstall-ChocolateyPackage `
28-
-PackageName "$packageName" `
29-
-FileType "$installerType" `
30-
-SilentArgs "$($silentArgs)" `
31-
-File "$($_.UninstallString.Replace('"',''))" `
32-
-ValidExitCodes $validExitCodes}
14+
For($i=0; $i -lt $software.Length; $i++) {
15+
[array]$key = Get-UninstallRegistryKey -SoftwareName $software[$i]
16+
17+
if ($key.Count -eq 1) {
18+
$key | ForEach-Object {
19+
$file = $($_.UninstallString)
20+
Start-Process $file -ArgumentList $silentArgs -Verb RunAs
21+
}
22+
} elseif ($key.Count -eq 0) {
23+
Write-Warning "$packageName has already been uninstalled by other means."
24+
} elseif ($key.Count -gt 1) {
25+
Write-Warning "$key.Count matches found!"
26+
Write-Warning "To prevent accidental data loss, no programs will be uninstalled."
27+
Write-Warning "Please alert package maintainer(s) the following keys were matched:"
28+
$key | ForEach-Object {Write-Warning "- $_.DisplayName"}
29+
}
30+
}
3331

3432
Remove-Item "$ahkRun" -Force

automatic/msiafterburner/tools/helpers.ps1

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)