Better reinstall
parent
7b23235e0f
commit
c125b77f86
|
@ -193,20 +193,22 @@ function Install-WingetAutoUpdate {
|
|||
Write-ToLog "Installing WAU..." "Yellow"
|
||||
|
||||
try {
|
||||
#Copy files to location (and clean old install)
|
||||
#Copy files to location
|
||||
if (!(Test-Path $WAUinstallPath)) {
|
||||
New-Item -ItemType Directory -Force -Path $WAUinstallPath | Out-Null
|
||||
Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
elseif (!$NoClean) {
|
||||
Remove-Item -Path "$WAUinstallPath\*" -Exclude *.log -Recurse -Force
|
||||
elseif ($NoClean) {
|
||||
#Keep critical files
|
||||
Get-ChildItem -Path $WAUinstallPath -Exclude *.txt, mods, logs, icons | Remove-Item -Recurse -Force
|
||||
Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WAUinstallPath -Exclude icons -Recurse -Force -ErrorAction SilentlyContinue #Exclude icons if personalized
|
||||
}
|
||||
else {
|
||||
#Keep critical files
|
||||
Get-ChildItem -Path $WAUinstallPath -Exclude *.txt, mods, logs | Remove-Item -Recurse -Force
|
||||
#Keep logs only
|
||||
Get-ChildItem -Path $WAUinstallPath -Exclude *.logs | Remove-Item -Recurse -Force
|
||||
Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue
|
||||
|
||||
#White List or Black List apps
|
||||
if ($UseWhiteList) {
|
||||
if (!$NoClean) {
|
||||
|
|
|
@ -137,15 +137,11 @@ function Invoke-PostUpdateActions {
|
|||
}
|
||||
|
||||
#Remove old registry key
|
||||
$RegistryKeys = @(
|
||||
"VersionMajor",
|
||||
"VersionMinor"
|
||||
)
|
||||
foreach ($RegistryKey in $RegistryKeys) {
|
||||
if (Get-ItemProperty -Path $regPath -Name $RegistryKey -ErrorAction SilentlyContinue) {
|
||||
Remove-ItemProperty -Path $regPath -Name $RegistryKey
|
||||
}
|
||||
}
|
||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "VersionMajor" -ErrorAction SilentlyContinue
|
||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "VersionMinor" -ErrorAction SilentlyContinue
|
||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "VersionMajor" -ErrorAction SilentlyContinue
|
||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "VersionMinor" -ErrorAction SilentlyContinue
|
||||
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "DisplayVersion" -ErrorAction SilentlyContinue
|
||||
|
||||
#Activate WAU in user context if previously configured (as "Winget-AutoUpdate-UserContext" at root)
|
||||
$UserContextTask = Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -TaskPath '\' -ErrorAction SilentlyContinue
|
||||
|
|
Loading…
Reference in New Issue