check update package install status prevent #77

This commit is contained in:
zoicware
2026-01-06 02:02:09 -05:00
committed by GitHub
parent 0a009c2a16
commit 4c3257d9b5

View File

@@ -878,8 +878,27 @@ function Install-NOAIPackage {
}
}
else {
Write-Status -msg 'Update package already installed... Skipping'
#Write-Host $($package | Select-Object *)
Write-Status -msg 'Update package already installed...'
}
Write-Status -msg 'Checking update package install status...'
$package = Get-WindowsPackage -Online | Where-Object { $_.PackageName -like '*zoicware*' }
if ($package.PackageState -eq 'InstallPending') {
Write-Status -msg 'Package installed incorrectly... Uninstalling!' -errorOutput
try {
Remove-WindowsPackage -Online -PackageName $package.PackageName -NoRestart -ErrorAction Stop
}
catch {
dism.exe /Online /remove-package /PackageName:$($package.PackageName) /NoRestart
}
#remove reg install location
$regPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages'
Get-ChildItem $regPath | ForEach-Object {
$value = try { Get-ItemProperty "registry::$($_.Name)" -ErrorAction Stop } catch { $null }
if ($value -and $value.PSPath -like '*zoicware*') {
Remove-Item -Path $value.PSPath -Recurse -Force
}
}
}
}
else {