From bfa098bfd7e5359c9db1bcc05092ec71bd68ebb5 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sat, 31 Aug 2024 13:49:39 +0200 Subject: [PATCH 1/3] Remove PreRelease version from Nightlies --- .github/workflows/WAU-AutoCreatePreVersion.yml | 2 +- Sources/WAU/Gui.ps1 | 2 +- Sources/WAU/Winget-AutoUpdate-Install.ps1 | 7 +------ Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/WAU-AutoCreatePreVersion.yml b/.github/workflows/WAU-AutoCreatePreVersion.yml index 8fda80e..b5d77d2 100644 --- a/.github/workflows/WAU-AutoCreatePreVersion.yml +++ b/.github/workflows/WAU-AutoCreatePreVersion.yml @@ -56,7 +56,7 @@ jobs: uses: MCKanpolat/auto-semver-action@5003b8d37f4b03d95f15303ea10242cbf7c13141 # 2 id: versioning with: - releaseType: prerelease + releaseType: Patch incrementPerCommit: false github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Sources/WAU/Gui.ps1 b/Sources/WAU/Gui.ps1 index da45dce..a521f2a 100644 --- a/Sources/WAU/Gui.ps1 +++ b/Sources/WAU/Gui.ps1 @@ -300,7 +300,7 @@ function Get-WAUConfiguratorLatestVersion { #Get latest stable info $WAUConfiguratorURL = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest' - $WAUConfiguratorLatestVersion = (((Invoke-WebRequest $WAUConfiguratorURL -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "")).Replace("-", ".") + $WAUConfiguratorLatestVersion = (((Invoke-WebRequest $WAUConfiguratorURL -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "")) if ([version]$WAUConfiguratorVersion -lt [version]$WAUConfiguratorLatestVersion) { diff --git a/Sources/WAU/Winget-AutoUpdate-Install.ps1 b/Sources/WAU/Winget-AutoUpdate-Install.ps1 index 1203bb5..c1d3620 100644 --- a/Sources/WAU/Winget-AutoUpdate-Install.ps1 +++ b/Sources/WAU/Winget-AutoUpdate-Install.ps1 @@ -263,12 +263,7 @@ function Install-WingetAutoUpdate { New-ItemProperty $regPath -Name Publisher -Value "Romanitho" -Force | Out-Null New-ItemProperty $regPath -Name URLInfoAbout -Value "https://github.com/Romanitho/Winget-AutoUpdate" -Force | Out-Null New-ItemProperty $regPath -Name WAU_NotificationLevel -Value $NotificationLevel -Force | Out-Null - if ($WAUVersion -match "-") { - New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 1 -PropertyType DWord -Force | Out-Null - } - else { - New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force | Out-Null - } + New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force | Out-Null New-ItemProperty $regPath -Name WAU_PostUpdateActions -Value 0 -PropertyType DWord -Force | Out-Null New-ItemProperty $regPath -Name WAU_MaxLogFiles -Value $MaxLogFiles -PropertyType DWord -Force | Out-Null New-ItemProperty $regPath -Name WAU_MaxLogSize -Value $MaxLogSize -PropertyType DWord -Force | Out-Null diff --git a/Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 index bc71e0d..47e95ca 100644 --- a/Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -149,7 +149,7 @@ if (Test-Network) { #Get Available Version $Script:WAUAvailableVersion = Get-WAUAvailableVersion #Compare - if ([version]$WAUAvailableVersion.Replace("-", ".") -ne [version]$WAUCurrentVersion.Replace("-", ".")) { + if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion) { #If new version is available, update it Write-ToLog "WAU Available version: $WAUAvailableVersion" "Yellow" Update-WAU From e16c12e4561f8becaa818bd594fc00eeb68a54e7 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sat, 31 Aug 2024 14:15:09 +0200 Subject: [PATCH 2/3] Move registry keys to future location --- Sources/WAU/Gui.ps1 | 8 +++---- Sources/WAU/Winget-AutoUpdate-Install.ps1 | 6 +++--- .../WAU/Winget-AutoUpdate/WAU-Policies.ps1 | 4 ++-- .../WAU/Winget-AutoUpdate/WAU-Uninstall.ps1 | 4 ++-- .../WAU/Winget-AutoUpdate/Winget-Install.ps1 | 2 +- .../WAU/Winget-AutoUpdate/Winget-Notify.ps1 | 2 +- .../functions/Get-WAUConfig.ps1 | 2 +- .../functions/Invoke-PostUpdateActions.ps1 | 21 +++++++++++++++---- .../functions/Update-WAU.ps1 | 4 ++-- .../mods/_AppID-template.ps1 | 4 ++-- 10 files changed, 35 insertions(+), 22 deletions(-) diff --git a/Sources/WAU/Gui.ps1 b/Sources/WAU/Gui.ps1 index a521f2a..3f46dfe 100644 --- a/Sources/WAU/Gui.ps1 +++ b/Sources/WAU/Gui.ps1 @@ -204,7 +204,7 @@ function Start-Installations { #Run Winget-Install script if box is checked if ($AppToInstall) { Start-PopUp "Installing applications..." - $WAUInstallPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation + $WAUInstallPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation #Try with admin rights. try { @@ -275,7 +275,7 @@ function Start-Uninstallations ($AppToUninstall) { } function Get-WAUInstallStatus { - $WAUVersion = Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\ -ErrorAction SilentlyContinue | Select-Object -ExpandProperty DisplayVersion -ErrorAction SilentlyContinue + $WAUVersion = Get-ItemProperty -Path HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\ -ErrorAction SilentlyContinue | Select-Object -ExpandProperty DisplayVersion -ErrorAction SilentlyContinue if ($WAUVersion -eq $WAUConfiguratorVersion) { $WAULabelText = "WAU is currently installed (v$WAUVersion)." $WAUStatus = "Green" @@ -577,7 +577,7 @@ function Start-InstallGUI { $UninstallWAUButton.add_click( { #Uninstall WAU from registry command - $Arguments = Get-ItemPropertyValue "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "UninstallString" + $Arguments = Get-ItemPropertyValue "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "UninstallString" Start-Process "cmd.exe" -ArgumentList "/c $Arguments" -Wait -Verb RunAs $WAUInstallStatus = Get-WAUInstallStatus $WAUStatusLabel.Text = $WAUInstallStatus[0] @@ -699,7 +699,7 @@ function Start-InstallGUI { $LogButton.add_click( { try { - $LogPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocatifon + $LogPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocatifon Start-Process "$LogPath\Logs" } catch { diff --git a/Sources/WAU/Winget-AutoUpdate-Install.ps1 b/Sources/WAU/Winget-AutoUpdate-Install.ps1 index c1d3620..a115b88 100644 --- a/Sources/WAU/Winget-AutoUpdate-Install.ps1 +++ b/Sources/WAU/Winget-AutoUpdate-Install.ps1 @@ -361,7 +361,7 @@ function Uninstall-WingetAutoUpdate { Write-ToLog "Uninstalling WAU started!" "Yellow" #Get registry install location - $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation -ErrorAction SilentlyContinue + $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation -ErrorAction SilentlyContinue #Check if installed location exists and delete if ($InstallLocation) { @@ -383,7 +383,7 @@ function Uninstall-WingetAutoUpdate { Get-ChildItem -Path $InstallLocation -Exclude *.txt, mods, logs | Remove-Item -Recurse -Force } & reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null - & reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null + & reg delete "HKLM\SOFTWARE\Romanitho\Winget-AutoUpdate" /f | Out-Null if ((Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) { Remove-Item -Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)" -Recurse -Force | Out-Null @@ -488,7 +488,7 @@ Write-Host "`t https://github.com/Romanitho/Winget-AutoUpdate`n" -Foreground Write-Host "`t________________________________________________________`n" #Define WAU registry key -$Script:regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" +$Script:regPath = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" if (!$Uninstall) { Write-ToLog " INSTALLING WAU" -LogColor "Cyan" -IsHeader diff --git a/Sources/WAU/Winget-AutoUpdate/WAU-Policies.ps1 b/Sources/WAU/Winget-AutoUpdate/WAU-Policies.ps1 index da104c9..e717d57 100644 --- a/Sources/WAU/Winget-AutoUpdate/WAU-Policies.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/WAU-Policies.ps1 @@ -14,7 +14,7 @@ Daily update settings from policies $ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue if ($ActivateGPOManagement -eq 1) { #Add (or update) tag to activate WAU-Policies Management - New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 1 -Force | Out-Null + New-ItemProperty "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 1 -Force | Out-Null } #Get WAU settings @@ -32,7 +32,7 @@ if ($WAUConfig.WAU_RunGPOManagement -eq 1) { Add-Content -Path $GPOLogFile -Value "GPO Management Enabled. Policies updated." } else { - New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 0 -Force | Out-Null + New-ItemProperty "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 0 -Force | Out-Null $WAUConfig.WAU_RunGPOManagement = 0 Add-Content -Path $GPOLogFile -Value "GPO Management Disabled. Policies removed." } diff --git a/Sources/WAU/Winget-AutoUpdate/WAU-Uninstall.ps1 b/Sources/WAU/Winget-AutoUpdate/WAU-Uninstall.ps1 index 5003189..a518bc2 100644 --- a/Sources/WAU/Winget-AutoUpdate/WAU-Uninstall.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/WAU-Uninstall.ps1 @@ -35,7 +35,7 @@ Write-Host "`t________________________________________________________`n`n" try { Write-host "Uninstalling WAU..." -ForegroundColor Yellow #Get registry install location - $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation + $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation #Check if installed location exists and delete if (Test-Path ($InstallLocation)) { @@ -52,7 +52,7 @@ try { Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False Get-ScheduledTask -TaskName "Winget-AutoUpdate-Policies" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False & reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null - & reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null + & reg delete "HKLM\SOFTWARE\Romanitho\Winget-AutoUpdate" /f | Out-Null if (Test-Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate") { & reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null } diff --git a/Sources/WAU/Winget-AutoUpdate/Winget-Install.ps1 b/Sources/WAU/Winget-AutoUpdate/Winget-Install.ps1 index ec24e6f..74fb768 100644 --- a/Sources/WAU/Winget-AutoUpdate/Winget-Install.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/Winget-Install.ps1 @@ -311,7 +311,7 @@ $CurrentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Pri $Script:IsElevated = $CurrentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) #Get WAU Installed location -$WAURegKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" +$WAURegKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" $Script:WAUInstallLocation = Get-ItemProperty $WAURegKey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty InstallLocation #LogPath initialisation diff --git a/Sources/WAU/Winget-AutoUpdate/Winget-Notify.ps1 b/Sources/WAU/Winget-AutoUpdate/Winget-Notify.ps1 index de22ef7..943d529 100644 --- a/Sources/WAU/Winget-AutoUpdate/Winget-Notify.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/Winget-Notify.ps1 @@ -1,7 +1,7 @@ #Send Notify Script #get xml notif config -$WAUinstalledPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation +$WAUinstalledPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation [xml]$NotifConf = Get-Content "$WAUinstalledPath\config\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue if (!($NotifConf)) { break diff --git a/Sources/WAU/Winget-AutoUpdate/functions/Get-WAUConfig.ps1 b/Sources/WAU/Winget-AutoUpdate/functions/Get-WAUConfig.ps1 index 6f9855c..5c371e0 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Get-WAUConfig.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Get-WAUConfig.ps1 @@ -3,7 +3,7 @@ Function Get-WAUConfig { #Get WAU Configurations from install config - $WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -ErrorAction SilentlyContinue + $WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -ErrorAction SilentlyContinue #Check if GPO Management is enabled $ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue diff --git a/Sources/WAU/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Sources/WAU/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index fa3db58..f28d76c 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -9,7 +9,7 @@ function Invoke-PostUpdateActions { $null = Update-WinGet #Create WAU Regkey if not present - $regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" + $regPath = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" if (!(test-path $regPath)) { New-Item $regPath -Force New-ItemProperty $regPath -Name DisplayName -Value "Winget-AutoUpdate (WAU)" -Force @@ -113,8 +113,8 @@ function Invoke-PostUpdateActions { } #Remove old registry key - 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\Romanitho\Winget-AutoUpdate" -Name "VersionMajor" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\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 @@ -143,11 +143,24 @@ function Invoke-PostUpdateActions { Write-ToLog "-> Policies task created." } + #Migrate registry to new location (MSI Prerequisites) + $sourcePath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" + $destinationPath = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" + if (-not (Test-Path (Split-Path $destinationPath))) { + New-Item -Path (Split-Path $destinationPath) -ItemType Directory + } + try { + Move-Item -Path $sourcePath -Destination $destinationPath -Force + Write-ToLog "-> Migrated registry from $sourcePath to $destinationPath." + } + catch { + Write-ToLog "-> Failed tro migrate registry to new location" + } ### End of post update actions ### #Reset WAU_UpdatePostActions Value - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "WAU_PostUpdateActions" -Value 0 -Force | Out-Null + New-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "WAU_PostUpdateActions" -Value 0 -Force | Out-Null #Get updated WAU Config $Script:WAUConfig = Get-WAUConfig diff --git a/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 index 4e4725f..6c32bef 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -46,10 +46,10 @@ function Update-WAU { Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue #Set new version to registry - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "DisplayVersion" -Value $WAUAvailableVersion -Force | Out-Null + New-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "DisplayVersion" -Value $WAUAvailableVersion -Force | Out-Null #Set Post Update actions to 1 - New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "WAU_PostUpdateActions" -Value 1 -Force | Out-Null + New-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "WAU_PostUpdateActions" -Value 1 -Force | Out-Null #Send success Notif Write-ToLog "WAU Update completed." "Green" diff --git a/Sources/WAU/Winget-AutoUpdate/mods/_AppID-template.ps1 b/Sources/WAU/Winget-AutoUpdate/mods/_AppID-template.ps1 index 85b09b7..c771856 100644 --- a/Sources/WAU/Winget-AutoUpdate/mods/_AppID-template.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/mods/_AppID-template.ps1 @@ -35,7 +35,7 @@ $AllVersions = $False $Lnk = @("") #Registry _value_ (DWord/String) to add in existing registry Key (Key created if not existing). Example: -#$AddKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" +#$AddKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" #$AddValue = "WAU_BypassListForUsers" #$AddTypeData = "1" #$AddType = "DWord" @@ -46,7 +46,7 @@ $AddType = "" #Registry _value_ to delete in existing registry Key. #Value can be omitted for deleting entire Key!. Example: -#$DelKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" +#$DelKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" #$DelValue = "WAU_BypassListForUsers" $DelKey = "" $DelValue = "" From 062c4f25412eaf7e6f4288751305d964588455a3 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sat, 31 Aug 2024 14:29:00 +0200 Subject: [PATCH 3/3] Revert "Move registry keys to future location" This reverts commit e16c12e4561f8becaa818bd594fc00eeb68a54e7. --- Sources/WAU/Gui.ps1 | 8 +++---- Sources/WAU/Winget-AutoUpdate-Install.ps1 | 6 +++--- .../WAU/Winget-AutoUpdate/WAU-Policies.ps1 | 4 ++-- .../WAU/Winget-AutoUpdate/WAU-Uninstall.ps1 | 4 ++-- .../WAU/Winget-AutoUpdate/Winget-Install.ps1 | 2 +- .../WAU/Winget-AutoUpdate/Winget-Notify.ps1 | 2 +- .../functions/Get-WAUConfig.ps1 | 2 +- .../functions/Invoke-PostUpdateActions.ps1 | 21 ++++--------------- .../functions/Update-WAU.ps1 | 4 ++-- .../mods/_AppID-template.ps1 | 4 ++-- 10 files changed, 22 insertions(+), 35 deletions(-) diff --git a/Sources/WAU/Gui.ps1 b/Sources/WAU/Gui.ps1 index 3f46dfe..a521f2a 100644 --- a/Sources/WAU/Gui.ps1 +++ b/Sources/WAU/Gui.ps1 @@ -204,7 +204,7 @@ function Start-Installations { #Run Winget-Install script if box is checked if ($AppToInstall) { Start-PopUp "Installing applications..." - $WAUInstallPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation + $WAUInstallPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation #Try with admin rights. try { @@ -275,7 +275,7 @@ function Start-Uninstallations ($AppToUninstall) { } function Get-WAUInstallStatus { - $WAUVersion = Get-ItemProperty -Path HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\ -ErrorAction SilentlyContinue | Select-Object -ExpandProperty DisplayVersion -ErrorAction SilentlyContinue + $WAUVersion = Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\ -ErrorAction SilentlyContinue | Select-Object -ExpandProperty DisplayVersion -ErrorAction SilentlyContinue if ($WAUVersion -eq $WAUConfiguratorVersion) { $WAULabelText = "WAU is currently installed (v$WAUVersion)." $WAUStatus = "Green" @@ -577,7 +577,7 @@ function Start-InstallGUI { $UninstallWAUButton.add_click( { #Uninstall WAU from registry command - $Arguments = Get-ItemPropertyValue "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "UninstallString" + $Arguments = Get-ItemPropertyValue "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "UninstallString" Start-Process "cmd.exe" -ArgumentList "/c $Arguments" -Wait -Verb RunAs $WAUInstallStatus = Get-WAUInstallStatus $WAUStatusLabel.Text = $WAUInstallStatus[0] @@ -699,7 +699,7 @@ function Start-InstallGUI { $LogButton.add_click( { try { - $LogPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocatifon + $LogPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocatifon Start-Process "$LogPath\Logs" } catch { diff --git a/Sources/WAU/Winget-AutoUpdate-Install.ps1 b/Sources/WAU/Winget-AutoUpdate-Install.ps1 index a115b88..c1d3620 100644 --- a/Sources/WAU/Winget-AutoUpdate-Install.ps1 +++ b/Sources/WAU/Winget-AutoUpdate-Install.ps1 @@ -361,7 +361,7 @@ function Uninstall-WingetAutoUpdate { Write-ToLog "Uninstalling WAU started!" "Yellow" #Get registry install location - $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation -ErrorAction SilentlyContinue + $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation -ErrorAction SilentlyContinue #Check if installed location exists and delete if ($InstallLocation) { @@ -383,7 +383,7 @@ function Uninstall-WingetAutoUpdate { Get-ChildItem -Path $InstallLocation -Exclude *.txt, mods, logs | Remove-Item -Recurse -Force } & reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null - & reg delete "HKLM\SOFTWARE\Romanitho\Winget-AutoUpdate" /f | Out-Null + & reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null if ((Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) { Remove-Item -Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)" -Recurse -Force | Out-Null @@ -488,7 +488,7 @@ Write-Host "`t https://github.com/Romanitho/Winget-AutoUpdate`n" -Foreground Write-Host "`t________________________________________________________`n" #Define WAU registry key -$Script:regPath = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" +$Script:regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" if (!$Uninstall) { Write-ToLog " INSTALLING WAU" -LogColor "Cyan" -IsHeader diff --git a/Sources/WAU/Winget-AutoUpdate/WAU-Policies.ps1 b/Sources/WAU/Winget-AutoUpdate/WAU-Policies.ps1 index e717d57..da104c9 100644 --- a/Sources/WAU/Winget-AutoUpdate/WAU-Policies.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/WAU-Policies.ps1 @@ -14,7 +14,7 @@ Daily update settings from policies $ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue if ($ActivateGPOManagement -eq 1) { #Add (or update) tag to activate WAU-Policies Management - New-ItemProperty "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 1 -Force | Out-Null + New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 1 -Force | Out-Null } #Get WAU settings @@ -32,7 +32,7 @@ if ($WAUConfig.WAU_RunGPOManagement -eq 1) { Add-Content -Path $GPOLogFile -Value "GPO Management Enabled. Policies updated." } else { - New-ItemProperty "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 0 -Force | Out-Null + New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 0 -Force | Out-Null $WAUConfig.WAU_RunGPOManagement = 0 Add-Content -Path $GPOLogFile -Value "GPO Management Disabled. Policies removed." } diff --git a/Sources/WAU/Winget-AutoUpdate/WAU-Uninstall.ps1 b/Sources/WAU/Winget-AutoUpdate/WAU-Uninstall.ps1 index a518bc2..5003189 100644 --- a/Sources/WAU/Winget-AutoUpdate/WAU-Uninstall.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/WAU-Uninstall.ps1 @@ -35,7 +35,7 @@ Write-Host "`t________________________________________________________`n`n" try { Write-host "Uninstalling WAU..." -ForegroundColor Yellow #Get registry install location - $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation + $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation #Check if installed location exists and delete if (Test-Path ($InstallLocation)) { @@ -52,7 +52,7 @@ try { Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False Get-ScheduledTask -TaskName "Winget-AutoUpdate-Policies" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False & reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null - & reg delete "HKLM\SOFTWARE\Romanitho\Winget-AutoUpdate" /f | Out-Null + & reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null if (Test-Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate") { & reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null } diff --git a/Sources/WAU/Winget-AutoUpdate/Winget-Install.ps1 b/Sources/WAU/Winget-AutoUpdate/Winget-Install.ps1 index 74fb768..ec24e6f 100644 --- a/Sources/WAU/Winget-AutoUpdate/Winget-Install.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/Winget-Install.ps1 @@ -311,7 +311,7 @@ $CurrentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Pri $Script:IsElevated = $CurrentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) #Get WAU Installed location -$WAURegKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" +$WAURegKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" $Script:WAUInstallLocation = Get-ItemProperty $WAURegKey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty InstallLocation #LogPath initialisation diff --git a/Sources/WAU/Winget-AutoUpdate/Winget-Notify.ps1 b/Sources/WAU/Winget-AutoUpdate/Winget-Notify.ps1 index 943d529..de22ef7 100644 --- a/Sources/WAU/Winget-AutoUpdate/Winget-Notify.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/Winget-Notify.ps1 @@ -1,7 +1,7 @@ #Send Notify Script #get xml notif config -$WAUinstalledPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation +$WAUinstalledPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation [xml]$NotifConf = Get-Content "$WAUinstalledPath\config\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue if (!($NotifConf)) { break diff --git a/Sources/WAU/Winget-AutoUpdate/functions/Get-WAUConfig.ps1 b/Sources/WAU/Winget-AutoUpdate/functions/Get-WAUConfig.ps1 index 5c371e0..6f9855c 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Get-WAUConfig.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Get-WAUConfig.ps1 @@ -3,7 +3,7 @@ Function Get-WAUConfig { #Get WAU Configurations from install config - $WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -ErrorAction SilentlyContinue + $WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -ErrorAction SilentlyContinue #Check if GPO Management is enabled $ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue diff --git a/Sources/WAU/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Sources/WAU/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 index f28d76c..fa3db58 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -9,7 +9,7 @@ function Invoke-PostUpdateActions { $null = Update-WinGet #Create WAU Regkey if not present - $regPath = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" + $regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" if (!(test-path $regPath)) { New-Item $regPath -Force New-ItemProperty $regPath -Name DisplayName -Value "Winget-AutoUpdate (WAU)" -Force @@ -113,8 +113,8 @@ function Invoke-PostUpdateActions { } #Remove old registry key - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "VersionMajor" -ErrorAction SilentlyContinue - Remove-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "VersionMinor" -ErrorAction SilentlyContinue + 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 @@ -143,24 +143,11 @@ function Invoke-PostUpdateActions { Write-ToLog "-> Policies task created." } - #Migrate registry to new location (MSI Prerequisites) - $sourcePath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" - $destinationPath = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" - if (-not (Test-Path (Split-Path $destinationPath))) { - New-Item -Path (Split-Path $destinationPath) -ItemType Directory - } - try { - Move-Item -Path $sourcePath -Destination $destinationPath -Force - Write-ToLog "-> Migrated registry from $sourcePath to $destinationPath." - } - catch { - Write-ToLog "-> Failed tro migrate registry to new location" - } ### End of post update actions ### #Reset WAU_UpdatePostActions Value - New-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "WAU_PostUpdateActions" -Value 0 -Force | Out-Null + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "WAU_PostUpdateActions" -Value 0 -Force | Out-Null #Get updated WAU Config $Script:WAUConfig = Get-WAUConfig diff --git a/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 index 6c32bef..4e4725f 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -46,10 +46,10 @@ function Update-WAU { Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue #Set new version to registry - New-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "DisplayVersion" -Value $WAUAvailableVersion -Force | Out-Null + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "DisplayVersion" -Value $WAUAvailableVersion -Force | Out-Null #Set Post Update actions to 1 - New-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name "WAU_PostUpdateActions" -Value 1 -Force | Out-Null + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "WAU_PostUpdateActions" -Value 1 -Force | Out-Null #Send success Notif Write-ToLog "WAU Update completed." "Green" diff --git a/Sources/WAU/Winget-AutoUpdate/mods/_AppID-template.ps1 b/Sources/WAU/Winget-AutoUpdate/mods/_AppID-template.ps1 index c771856..85b09b7 100644 --- a/Sources/WAU/Winget-AutoUpdate/mods/_AppID-template.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/mods/_AppID-template.ps1 @@ -35,7 +35,7 @@ $AllVersions = $False $Lnk = @("") #Registry _value_ (DWord/String) to add in existing registry Key (Key created if not existing). Example: -#$AddKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" +#$AddKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" #$AddValue = "WAU_BypassListForUsers" #$AddTypeData = "1" #$AddType = "DWord" @@ -46,7 +46,7 @@ $AddType = "" #Registry _value_ to delete in existing registry Key. #Value can be omitted for deleting entire Key!. Example: -#$DelKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" +#$DelKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" #$DelValue = "WAU_BypassListForUsers" $DelKey = "" $DelValue = ""