From be84e24fa948dc5a38859a0ba536bbb5784b1333 Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Mon, 23 May 2022 00:29:46 +0200 Subject: [PATCH] Revert " Update job improved" --- Winget-AutoUpdate-Install.ps1 | 1 - .../functions/Invoke-PostUpdateActions.ps1 | 62 ------------------- Winget-AutoUpdate/functions/Update-WAU.ps1 | 11 ++-- Winget-AutoUpdate/winget-upgrade.ps1 | 11 +--- 4 files changed, 7 insertions(+), 78 deletions(-) delete mode 100644 Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index f96eaa6..eca2464 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -231,7 +231,6 @@ function Install-WingetAutoUpdate{ New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force if ($UseWhiteList) {New-ItemProperty $regPath -Name WAU_UseWhiteList -Value 1 -PropertyType DWord -Force} New-ItemProperty $regPath -Name WAU_NotificationLevel -Value $NotificationLevel -Force - New-ItemProperty $regPath -Name WAU_UpdatePostActions -Value 0 -PropertyType DWord -Force Write-host "`nWAU Installation succeeded!" -ForegroundColor Green Start-sleep 1 diff --git a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 deleted file mode 100644 index b82978d..0000000 --- a/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 +++ /dev/null @@ -1,62 +0,0 @@ -#Function to make actions post WAU update - -function Invoke-PostUpdateActions { - - Write-Log "Running Post Update actions..." "yellow" - - #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 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 "$WorkingDir\WAU-Uninstall.bat" -Force - New-ItemProperty $regPath -Name QuietUninstallString -Value "$WorkingDir\WAU-Uninstall.bat" -Force - New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force - } - - #Convert about.xml if exists (previous 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 - New-ItemProperty $regPath -Name VersionMajor -Value ([version]$About.app.version).Major -Force - New-ItemProperty $regPath -Name VersionMinor -Value ([version]$About.app.version).Minor -Force - - #Remove file once converted - Remove-Item $WAUAboutPath -Force -Confirm:$false - } - - #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 - } - - #Remove old functions - $FileNames = @( - "$WorkingDir\functions\Get-WAUConfig.ps1", - "$WorkingDir\functions\Get-WAUCurrentVersion.ps1", - "$WorkingDir\functions\Get-WAUUpdateStatus.ps1" - ) - foreach ($FileName in $FileNames){ - if (Test-Path $FileName) { - Remove-Item $FileName -Force -Confirm:$false - } - } - - #Reset WAU_UpdatePostActions Value - $WAUConfig | New-ItemProperty -Name WAU_PostUpdateActions -Value 0 -Force - -} \ No newline at end of file diff --git a/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Winget-AutoUpdate/functions/Update-WAU.ps1 index 8cfb8ff..9e41b52 100644 --- a/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -39,12 +39,9 @@ function Update-WAU { Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue #Set new version to registry - $WAUConfig | New-ItemProperty -Name DisplayVersion -Value $WAUAvailableVersion -Force - $WAUConfig | New-ItemProperty -Name VersionMajor -Value ([version]$WAUAvailableVersion).Major -Force - $WAUConfig | New-ItemProperty -Name VersionMinor -Value ([version]$WAUAvailableVersion).Minor -Force - - #Set Post Update actions to 1 - $WAUConfig | New-ItemProperty -Name WAU_PostUpdateActions -Value 1 -Force + $WAUConfig | New-ItemProperty $regPath -Name DisplayVersion -Value $WAUAvailableVersion -Force + $WAUConfig | New-ItemProperty $regPath -Name VersionMajor -Value ([version]$WAUAvailableVersion).Major -Force + $WAUConfig | New-ItemProperty $regPath -Name VersionMinor -Value ([version]$WAUAvailableVersion).Minor -Force #Send success Notif Write-Log "WAU Update completed." "Green" @@ -56,7 +53,7 @@ function Update-WAU { #Rerun with newer version Write-Log "Re-run WAU" - Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"$WorkingDir\winget-upgrade.ps1`"" + Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"$WorkingDir\winget-upgrade`"" exit diff --git a/Winget-AutoUpdate/winget-upgrade.ps1 b/Winget-AutoUpdate/winget-upgrade.ps1 index 3591717..756b2cd 100644 --- a/Winget-AutoUpdate/winget-upgrade.ps1 +++ b/Winget-AutoUpdate/winget-upgrade.ps1 @@ -11,20 +11,15 @@ Get-ChildItem "$WorkingDir\functions" | ForEach-Object {. $_.FullName} #Run log initialisation function Start-Init -#Get WAU Configurations -$Script:WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" - -#Run post update actions -if (!($WAUConfig.WAU_UpdatePostActions -eq 0)){ - -} - #Run Scope Machine funtion if run as system if ([System.Security.Principal.WindowsIdentity]::GetCurrent().IsSystem) { $SettingsPath = "$Env:windir\system32\config\systemprofile\AppData\Local\Microsoft\WinGet\Settings\settings.json" Add-ScopeMachine $SettingsPath } +#Get WAU Configurations +$Script:WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" + #Get Notif Locale function Get-NotifLocale