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