Update job improved
parent
8acff24678
commit
4716072211
|
@ -231,6 +231,7 @@ function Install-WingetAutoUpdate{
|
||||||
New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force
|
New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force
|
||||||
if ($UseWhiteList) {New-ItemProperty $regPath -Name WAU_UseWhiteList -Value 1 -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_NotificationLevel -Value $NotificationLevel -Force
|
||||||
|
New-ItemProperty $regPath -Name WAU_UpdatePostActions -Value 0 -PropertyType DWord -Force
|
||||||
|
|
||||||
Write-host "`nWAU Installation succeeded!" -ForegroundColor Green
|
Write-host "`nWAU Installation succeeded!" -ForegroundColor Green
|
||||||
Start-sleep 1
|
Start-sleep 1
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
#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
|
||||||
|
|
||||||
|
}
|
|
@ -39,9 +39,12 @@ function Update-WAU {
|
||||||
Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue
|
Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
#Set new version to registry
|
#Set new version to registry
|
||||||
$WAUConfig | New-ItemProperty $regPath -Name DisplayVersion -Value $WAUAvailableVersion -Force
|
$WAUConfig | New-ItemProperty -Name DisplayVersion -Value $WAUAvailableVersion -Force
|
||||||
$WAUConfig | New-ItemProperty $regPath -Name VersionMajor -Value ([version]$WAUAvailableVersion).Major -Force
|
$WAUConfig | New-ItemProperty -Name VersionMajor -Value ([version]$WAUAvailableVersion).Major -Force
|
||||||
$WAUConfig | New-ItemProperty $regPath -Name VersionMinor -Value ([version]$WAUAvailableVersion).Minor -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
|
||||||
|
|
||||||
#Send success Notif
|
#Send success Notif
|
||||||
Write-Log "WAU Update completed." "Green"
|
Write-Log "WAU Update completed." "Green"
|
||||||
|
@ -53,7 +56,7 @@ function Update-WAU {
|
||||||
|
|
||||||
#Rerun with newer version
|
#Rerun with newer version
|
||||||
Write-Log "Re-run WAU"
|
Write-Log "Re-run WAU"
|
||||||
Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"$WorkingDir\winget-upgrade`""
|
Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"$WorkingDir\winget-upgrade.ps1`""
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
||||||
|
|
|
@ -11,15 +11,20 @@ Get-ChildItem "$WorkingDir\functions" | ForEach-Object {. $_.FullName}
|
||||||
#Run log initialisation function
|
#Run log initialisation function
|
||||||
Start-Init
|
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
|
#Run Scope Machine funtion if run as system
|
||||||
if ([System.Security.Principal.WindowsIdentity]::GetCurrent().IsSystem) {
|
if ([System.Security.Principal.WindowsIdentity]::GetCurrent().IsSystem) {
|
||||||
$SettingsPath = "$Env:windir\system32\config\systemprofile\AppData\Local\Microsoft\WinGet\Settings\settings.json"
|
$SettingsPath = "$Env:windir\system32\config\systemprofile\AppData\Local\Microsoft\WinGet\Settings\settings.json"
|
||||||
Add-ScopeMachine $SettingsPath
|
Add-ScopeMachine $SettingsPath
|
||||||
}
|
}
|
||||||
|
|
||||||
#Get WAU Configurations
|
|
||||||
$Script:WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
|
|
||||||
|
|
||||||
#Get Notif Locale function
|
#Get Notif Locale function
|
||||||
Get-NotifLocale
|
Get-NotifLocale
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue