...and, missing list error too!

pull/245/head
KnifMelti 2022-12-11 22:22:22 +01:00
parent 7c0c9dcb30
commit 50b2d383c4
2 changed files with 21 additions and 12 deletions

View File

@ -82,10 +82,10 @@ else {
Start-Sleep 3 Start-Sleep 3
} }
#Test if there was a winget error as System/User #Test if there was a list/winget error as System/User
if (Test-Path "$WorkingDir\winget_error.txt") { if (Test-Path "$WorkingDir\*_error.txt") {
$MessageType = "error" $MessageType = "error"
Remove-Item "$WorkingDir\winget_error.txt" -Force Remove-Item "$WorkingDir\*_error.txt" -Force
} }
elseif (Test-Path "${env:TEMP}\winget_error.txt") { elseif (Test-Path "${env:TEMP}\winget_error.txt") {
$MessageType = "error" $MessageType = "error"

View File

@ -36,6 +36,14 @@ if ($IsSystem) {
Add-ScopeMachine $SettingsPath Add-ScopeMachine $SettingsPath
} }
#Delete previous list/winget_error (if they exist) as System/User
if ($IsSystem -and (Test-Path "$WorkingDir\*_error.txt")) {
Remove-Item "$WorkingDir\*_error.txt" -Force
}
elseif (!$IsSystem -and (Test-Path "${env:TEMP}\winget_error.txt")) {
Remove-Item "${env:TEMP}\winget_error.txt" -Force
}
#Get Notif Locale function #Get Notif Locale function
$LocaleDisplayName = Get-NotifLocale $LocaleDisplayName = Get-NotifLocale
Write-Log "Notification Level: $($WAUConfig.WAU_NotificationLevel). Notification Language: $LocaleDisplayName" "Cyan" Write-Log "Notification Level: $($WAUConfig.WAU_NotificationLevel). Notification Language: $LocaleDisplayName" "Cyan"
@ -83,7 +91,16 @@ if (Test-Network) {
Write-Log "List is up to date." "Green" Write-Log "List is up to date." "Green"
} }
else { else {
Write-Log "List doesn't exist!" "Red" Write-Log "Critical: List doesn't exist, exiting..." "Red"
$path = "$WorkingDir\list_error.txt"
New-Item "$path" -Force
#Setting file rights for everyone (so that it can be deleted by User in User-Run.ps1)
$rule= New-Object System.Security.AccessControl.FileSystemAccessRule ('Everyone', 'FullControl', 'Allow')
$acl = Get-ACL $path
$acl.SetAccessRule($rule)
Set-ACL -Path $path -AclObject $acl
Exit 1 Exit 1
} }
} }
@ -110,14 +127,6 @@ if (Test-Network) {
} }
} }
#Delete previous winget_error (if exists) as System/User
if ($IsSystem -and (Test-Path "$WorkingDir\winget_error.txt")) {
Remove-Item "$WorkingDir\winget_error.txt" -Force
}
elseif (!$IsSystem -and (Test-Path "${env:TEMP}\winget_error.txt")) {
Remove-Item "${env:TEMP}\winget_error.txt" -Force
}
#Get White or Black list #Get White or Black list
if ($WAUConfig.WAU_UseWhiteList -eq 1) { if ($WAUConfig.WAU_UseWhiteList -eq 1) {
Write-Log "WAU uses White List config" Write-Log "WAU uses White List config"