mirror of
https://github.com/zoicware/RemoveWindowsAI.git
synced 2026-01-10 17:54:50 +01:00
check update package install status prevent #77
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user