Maybe som optimizations/millisecs...

pull/219/head
KnifMelti 2022-10-26 21:44:41 +02:00
parent fa1004f4b7
commit e5bc0b663c
1 changed files with 29 additions and 32 deletions

View File

@ -51,28 +51,25 @@ if (Test-Network) {
Write-Log "WAU current version: $WAUCurrentVersion" Write-Log "WAU current version: $WAUCurrentVersion"
#Check if WAU update feature is enabled or not #Check if WAU update feature is enabled or not
$WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate $WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate
#If yes then check WAU update #If yes then check WAU update if System
if ($WAUDisableAutoUpdate -eq 1) { if ($IsSystem) {
Write-Log "WAU AutoUpdate is Disabled." "Grey" if ($WAUDisableAutoUpdate -eq 1) {
} Write-Log "WAU AutoUpdate is Disabled." "Grey"
else { }
Write-Log "WAU AutoUpdate is Enabled." "Green" else {
#Get Available Version Write-Log "WAU AutoUpdate is Enabled." "Green"
$WAUAvailableVersion = Get-WAUAvailableVersion #Get Available Version
#Compare $WAUAvailableVersion = Get-WAUAvailableVersion
if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion) { #Compare
#If new version is available, update it if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion) {
Write-Log "WAU Available version: $WAUAvailableVersion" "Yellow" #If new version is available, update it
if ($IsSystem) { Write-Log "WAU Available version: $WAUAvailableVersion" "Yellow"
Update-WAU Update-WAU
} }
else { else {
Write-Log "WAU Needs to run as system to update" "Yellow" Write-Log "WAU is up to date." "Green"
} }
} }
else {
Write-Log "WAU is up to date." "Green"
}
} }
if ($IsSystem) { if ($IsSystem) {
@ -169,23 +166,23 @@ if (Test-Network) {
Write-Log "No new update." "Green" Write-Log "No new update." "Green"
} }
} }
}
#Run WAU in user context if currently as system
if ($IsSystem) {
#Run WAU in user context if currently as system #Get Winget system apps to excape them befor running user context
if ($IsSystem) { Get-WingetSystemApps
#Get Winget system apps to excape them befor running user context #Run user context scheduled task
Get-WingetSystemApps $UserScheduledTask = Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue
if ($UserScheduledTask) {
#Run user context scheduled task Write-Log "Starting WAU in User context"
$UserScheduledTask = Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue Start-ScheduledTask $UserScheduledTask.TaskName -ErrorAction SilentlyContinue
if ($UserScheduledTask) { Exit 0
Write-Log "Starting WAU in User context" }
Start-ScheduledTask $UserScheduledTask.TaskName -ErrorAction SilentlyContinue else {
Exit 0 Write-Log "User context execution not installed"
} }
else {
Write-Log "User context execution not installed"
} }
} }