Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSI Prerequisites] Registry migration before msi upgrade #674

Merged
merged 1 commit into from
Sep 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,25 @@ function Update-WAU {
$MsiFile = "$env:temp\WAU.msi"
Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$($WAUAvailableVersion)/WAU.msi" -OutFile $MsiFile


#Migrate registry to save current WAU settings
Write-ToLog "Saving current config before updating with MSI"
$sourcePath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
$destinationPath = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate"
#Create the destination key if it doesn't exist
if (-not (Test-Path -Path $destinationPath)) {
New-Item -Path $destinationPath -ItemType Directory -Force
Write-ToLog "New registry key created."
}
#Retrieve the properties of the source key
$properties = Get-ItemProperty -Path $sourcePath
foreach ($property in $properties.PSObject.Properties) {
#Check if the value name starts with "WAU_"
if ($property.Name -like "WAU_*") {
#Copy the value to the destination key
Set-ItemProperty -Path $destinationPath -Name $property.Name -Value $property.Value
Write-ToLog "$($property.Name) saved."
}
}

#Update WAU and run
Write-ToLog "Updating WAU..." "Yellow"
Expand Down Expand Up @@ -104,4 +122,4 @@ function Update-WAU {
}
}

}
}
Loading