Skip to content

Commit c6b5ee7

Browse files
committed
Forgot $ModsPreUninstall - DONE!
1 parent 497085e commit c6b5ee7

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Sources/Winget-AutoUpdate/Winget-Install.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,12 @@ function Uninstall-App ($AppID, $AppArgs) {
207207

208208
#If PreUninstall script exist
209209
if ($ModsPreUninstall) {
210-
Write-ToLog "-> Modifications for $AppID before uninstall are being applied..." "DarkYellow" -Component "WinGet-Install"
211-
& "$ModsPreUninstall"
210+
Write-ToLog "Modifications for $AppID before uninstall are being applied..." "DarkYellow" -Component "WinGet-Install"
211+
$preUnInstallResult = & "$ModsPreUnInstall"
212+
if ($preUnInstallResult -eq $false) {
213+
Write-ToLog "PreUnInstall script for $AppID requested to skip this uninstallation" "Yellow" -Component "WinGet-Install"
214+
return # Exit the function early
215+
}
212216
}
213217

214218
#Uninstall App

Sources/Winget-AutoUpdate/mods/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The **-install** mod will be used for upgrades too if **-upgrade** doesn't exist
2424

2525
`AppID-install.ps1` is recommended because it's used in **both** scenarios.
2626

27-
If **AppID**`-preinstall.ps1` returns `$false`, the install/update for that **AppID** is skipped (checking if an App is running, etc...).
27+
If **AppID**`-preinstall.ps1`/`-preuninstall.ps1` returns `$false`, the install/update/uninstall for that **AppID** is skipped (checking if an App is running, etc...).
2828

2929
A script **Template** for an all-purpose mod (`_WAU-notinstalled-template.ps1`) is included in which actions can be taken if an upgrade/install fails for any **AppID** (any individual `AppID-notinstalled.ps1` overrides this global one)
3030
Name it `_WAU-notinstalled.ps1` for activation

0 commit comments

Comments
 (0)