If usertask not installed, end

pull/219/head
KnifMelti 2022-10-26 22:43:13 +02:00
parent deb734934d
commit cc7e989e5c
1 changed files with 6 additions and 11 deletions

View File

@ -164,22 +164,17 @@ if (Test-Network) {
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 and the user task exist
$UserScheduledTask = Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue
if ($IsSystem -and $UserScheduledTask) {
#Get Winget system apps to excape them befor running user context
Get-WingetSystemApps
#Run user context scheduled task
$UserScheduledTask = Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue
if ($UserScheduledTask) {
Write-Log "Starting WAU in User context"
Start-ScheduledTask $UserScheduledTask.TaskName -ErrorAction SilentlyContinue
Exit 0
}
else {
Write-Log "User context execution not installed"
}
Write-Log "Starting WAU in User context"
Start-ScheduledTask $UserScheduledTask.TaskName -ErrorAction SilentlyContinue
Exit 0
}
}
}