From 8e58617f6e9f299c3a30ee76c04e11d3e0c64c23 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:58:04 +0200 Subject: [PATCH] Migrate Reg Config --- Sources/WAU/Gui.ps1 | 8 +- Sources/WAU/Winget-AutoUpdate-Install.ps1 | 27 +++-- .../WAU/Winget-AutoUpdate/WAU-Policies.ps1 | 4 +- .../WAU/Winget-AutoUpdate/WAU-Uninstall.ps1 | 3 +- .../WAU/Winget-AutoUpdate/Winget-Install.ps1 | 2 +- .../WAU/Winget-AutoUpdate/Winget-Notify.ps1 | 2 +- .../WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 | 2 +- .../functions/Get-WAUConfig.ps1 | 2 +- .../functions/Invoke-PostUpdateActions.ps1 | 102 ++++++++---------- .../functions/Update-WAU.ps1 | 3 +- .../mods/_AppID-template.ps1 | 6 +- 11 files changed, 76 insertions(+), 85 deletions(-) diff --git a/Sources/WAU/Gui.ps1 b/Sources/WAU/Gui.ps1 index da45dcea..f3cc8207 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 1203bb57..60d8b982 100644 --- a/Sources/WAU/Winget-AutoUpdate-Install.ps1 +++ b/Sources/WAU/Winget-AutoUpdate-Install.ps1 @@ -252,16 +252,19 @@ function Install-WingetAutoUpdate { # Configure Reg Key Write-ToLog "-> Setting Registry config" New-Item $regPath -Force | Out-Null - New-ItemProperty $regPath -Name DisplayName -Value "Winget-AutoUpdate (WAU)" -Force | Out-Null - New-ItemProperty $regPath -Name DisplayIcon -Value "C:\Windows\System32\shell32.dll,-16739" -Force | Out-Null - New-ItemProperty $regPath -Name DisplayVersion -Value $WAUVersion -Force | Out-Null + New-Item $InstallregPath -Force | Out-Null + New-ItemProperty $InstallregPath -Name DisplayName -Value "Winget-AutoUpdate (WAU)" -Force | Out-Null + New-ItemProperty $InstallregPath -Name DisplayIcon -Value "C:\Windows\System32\shell32.dll,-16739" -Force | Out-Null + New-ItemProperty $InstallregPath -Name DisplayVersion -Value $WAUVersion -Force | Out-Null + New-ItemProperty $regPath -Name ProductVersion -Value $WAUVersion -Force | Out-Null + New-ItemProperty $InstallregPath -Name InstallLocation -Value $WAUinstallPath -Force | Out-Null New-ItemProperty $regPath -Name InstallLocation -Value $WAUinstallPath -Force | Out-Null - New-ItemProperty $regPath -Name UninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WAUinstallPath\WAU-Uninstall.ps1`"" -Force | Out-Null - New-ItemProperty $regPath -Name QuietUninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WAUinstallPath\WAU-Uninstall.ps1`"" -Force | Out-Null - New-ItemProperty $regPath -Name NoModify -Value 1 -Force | Out-Null - New-ItemProperty $regPath -Name NoRepair -Value 1 -Force | Out-Null - 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 $InstallregPath -Name UninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WAUinstallPath\WAU-Uninstall.ps1`"" -Force | Out-Null + New-ItemProperty $InstallregPath -Name QuietUninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WAUinstallPath\WAU-Uninstall.ps1`"" -Force | Out-Null + New-ItemProperty $InstallregPath -Name NoModify -Value 1 -Force | Out-Null + New-ItemProperty $InstallregPath -Name NoRepair -Value 1 -Force | Out-Null + New-ItemProperty $InstallregPath -Name Publisher -Value "Romanitho" -Force | Out-Null + New-ItemProperty $InstallregPath -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 @@ -366,7 +369,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) { @@ -389,6 +392,7 @@ function Uninstall-WingetAutoUpdate { } & 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 @@ -493,7 +497,8 @@ 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" +$Script:InstallregPath = "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 da104c9a..e717d579 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 5003189f..6a24a608 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)) { @@ -53,6 +53,7 @@ try { 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 ec24e6f1..74fb7685 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 de22ef7d..943d5298 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/Winget-Upgrade.ps1 b/Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 index bc71e0dc..4bf15161 100644 --- a/Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -135,7 +135,7 @@ if (Test-Network) { Write-ToLog "Winget Version: $WingetVer" #Get Current Version - $WAUCurrentVersion = $WAUConfig.DisplayVersion + $WAUCurrentVersion = $WAUConfig.ProductVersion Write-ToLog "WAU current version: $WAUCurrentVersion" if ($IsSystem) { #Check if WAU update feature is enabled or not if run as System diff --git a/Sources/WAU/Winget-AutoUpdate/functions/Get-WAUConfig.ps1 b/Sources/WAU/Winget-AutoUpdate/functions/Get-WAUConfig.ps1 index 6f9855c7..5c371e03 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 fa3db58f..06cccc5d 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 @@ -8,38 +8,58 @@ function Invoke-PostUpdateActions { #Update Winget if not up to date $null = Update-WinGet - #Create WAU Regkey if not present - $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 - New-ItemProperty $regPath -Name DisplayIcon -Value "C:\Windows\System32\shell32.dll,-16739" -Force - New-ItemProperty $regPath -Name NoModify -Value 1 -Force - New-ItemProperty $regPath -Name NoRepair -Value 1 -Force - New-ItemProperty $regPath -Name Publisher -Value "Romanitho" -Force - New-ItemProperty $regPath -Name URLInfoAbout -Value "https://github.com/Romanitho/Winget-AutoUpdate" -Force - New-ItemProperty $regPath -Name InstallLocation -Value $WorkingDir -Force - New-ItemProperty $regPath -Name UninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WorkingDir\WAU-Uninstall.ps1`"" -Force - New-ItemProperty $regPath -Name QuietUninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WorkingDir\WAU-Uninstall.ps1`"" -Force - New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force - + #Create WAU Regkeys if not present + $InstallRegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" + if (!(test-path $InstallRegPath)) { + New-Item $InstallRegPath -Force + New-ItemProperty $InstallRegPath -Name DisplayName -Value "Winget-AutoUpdate (WAU)" -Force + New-ItemProperty $InstallRegPath -Name DisplayIcon -Value "C:\Windows\System32\shell32.dll,-16739" -Force + New-ItemProperty $InstallRegPath -Name NoModify -Value 1 -Force + New-ItemProperty $InstallRegPath -Name NoRepair -Value 1 -Force + New-ItemProperty $InstallRegPath -Name Publisher -Value "Romanitho" -Force + New-ItemProperty $InstallRegPath -Name URLInfoAbout -Value "https://github.com/Romanitho/Winget-AutoUpdate" -Force + New-ItemProperty $InstallRegPath -Name UninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WorkingDir\WAU-Uninstall.ps1`"" -Force + New-ItemProperty $InstallRegPath -Name QuietUninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WorkingDir\WAU-Uninstall.ps1`"" -Force + #log + Write-ToLog "-> $InstallRegPath created." "green" + } + #Migrate configuration if not already done + $ConfigRegPath = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" + if (!(test-path $ConfigRegPath)) { + New-Item -Path $ConfigRegPath -Force + New-ItemProperty $ConfigRegPath -Name InstallLocation -Value $WorkingDir -Force + $Keys = Get-Item $InstallRegPath + foreach ($Key in $Keys.Property) { + if ($Key -like "WAU_*") { + Move-ItemProperty $InstallRegPath -Name $Key -Destination $ConfigRegPath + } + elseif ($Key -eq "DisplayVersion") { + Copy-ItemProperty $InstallRegPath -Name "DisplayVersion" -Destination $ConfigRegPath + Rename-ItemProperty $ConfigRegPath -Name "DisplayVersion" -NewName "ProductVersion" + } + elseif ($Key -eq "InstallLocation") { + Copy-ItemProperty $InstallRegPath -Name $Key -Destination $ConfigRegPath + } + } #log - Write-ToLog "-> $regPath created." "green" + Write-ToLog "-> $ConfigRegPath created. Config migrated." "green" + #Reload config + $Script:WAUConfig = Get-WAUConfig } #Fix Notif where WAU_NotificationLevel is not set - $regNotif = Get-ItemProperty $regPath -Name WAU_NotificationLevel -ErrorAction SilentlyContinue + $regNotif = Get-ItemProperty $ConfigRegPath -Name WAU_NotificationLevel -ErrorAction SilentlyContinue if (!$regNotif) { - New-ItemProperty $regPath -Name WAU_NotificationLevel -Value Full -Force + New-ItemProperty $ConfigRegPath -Name WAU_NotificationLevel -Value Full -Force #log Write-ToLog "-> Notification level setting was missing. Fixed with 'Full' option." } #Set WAU_MaxLogFiles/WAU_MaxLogSize if not set - $MaxLogFiles = Get-ItemProperty $regPath -Name WAU_MaxLogFiles -ErrorAction SilentlyContinue + $MaxLogFiles = Get-ItemProperty $ConfigRegPath -Name WAU_MaxLogFiles -ErrorAction SilentlyContinue if (!$MaxLogFiles) { - New-ItemProperty $regPath -Name WAU_MaxLogFiles -Value 3 -PropertyType DWord -Force | Out-Null - New-ItemProperty $regPath -Name WAU_MaxLogSize -Value 1048576 -PropertyType DWord -Force | Out-Null + New-ItemProperty $ConfigRegPath -Name WAU_MaxLogFiles -Value 3 -PropertyType DWord -Force | Out-Null + New-ItemProperty $ConfigRegPath -Name WAU_MaxLogSize -Value 1048576 -PropertyType DWord -Force | Out-Null #log Write-ToLog "-> MaxLogFiles/MaxLogSize setting was missing. Fixed with 3/1048576 (in bytes, default is 1048576 = 1 MB)." @@ -63,35 +83,6 @@ function Invoke-PostUpdateActions { Write-ToLog "-> Error: The Functions directory couldn't be verified as secured!" "red" } - #Convert about.xml if exists (old WAU versions) to reg - $WAUAboutPath = "$WorkingDir\config\about.xml" - if (test-path $WAUAboutPath) { - [xml]$About = Get-Content $WAUAboutPath -Encoding UTF8 -ErrorAction SilentlyContinue - New-ItemProperty $regPath -Name DisplayVersion -Value $About.app.version -Force - - #Remove file once converted - Remove-Item $WAUAboutPath -Force -Confirm:$false - - #log - Write-ToLog "-> $WAUAboutPath converted." "green" - } - - #Convert config.xml if exists (previous WAU versions) to reg - $WAUConfigPath = "$WorkingDir\config\config.xml" - if (test-path $WAUConfigPath) { - [xml]$Config = Get-Content $WAUConfigPath -Encoding UTF8 -ErrorAction SilentlyContinue - if ($Config.app.WAUautoupdate -eq "False") { New-ItemProperty $regPath -Name WAU_DisableAutoUpdate -Value 1 -Force } - if ($Config.app.NotificationLevel) { New-ItemProperty $regPath -Name WAU_NotificationLevel -Value $Config.app.NotificationLevel -Force } - if ($Config.app.UseWAUWhiteList -eq "True") { New-ItemProperty $regPath -Name WAU_UseWhiteList -Value 1 -PropertyType DWord -Force } - if ($Config.app.WAUprerelease -eq "True") { New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 1 -PropertyType DWord -Force } - - #Remove file once converted - Remove-Item $WAUConfigPath -Force -Confirm:$false - - #log - Write-ToLog "-> $WAUConfigPath converted." "green" - } - #Remove old functions / files $FileNames = @( "$WorkingDir\functions\Start-Init.ps1", @@ -112,13 +103,6 @@ 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\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 if ($UserContextTask) { @@ -126,7 +110,7 @@ function Invoke-PostUpdateActions { $null = $UserContextTask | Unregister-ScheduledTask -Confirm:$False #Set it in registry as activated. - New-ItemProperty $regPath -Name WAU_UserContext -Value 1 -PropertyType DWord -Force | Out-Null + New-ItemProperty $ConfigRegPath -Name WAU_UserContext -Value 1 -PropertyType DWord -Force | Out-Null Write-ToLog "-> Old User Context task deleted and set to 'enabled' in registry." } @@ -147,7 +131,7 @@ function Invoke-PostUpdateActions { ### 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 4e4725fc..34989169 100644 --- a/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Sources/WAU/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -47,9 +47,10 @@ function Update-WAU { #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 "ProductVersion" -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 85b09b70..386cfd74 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 = "" @@ -93,7 +93,7 @@ if ($Proc) { Stop-ModsProc $Proc } if ($Svc) { - Stop-ModsSvc $Svc + Stop-ModsSvc $Svc } if ($Wait) { Wait-ModsProc $Wait