Old School Error Handling (by file)
parent
d6abb076c3
commit
3a7694f9e2
|
@ -49,7 +49,7 @@ $Balise = "Winget-AutoUpdate (WAU)"
|
|||
$UserRun = $True
|
||||
|
||||
if ($Logs) {
|
||||
if ((Test-Path "$WorkingDir\logs\updates.log")) {
|
||||
if (Test-Path "$WorkingDir\logs\updates.log") {
|
||||
Invoke-Item "$WorkingDir\logs\updates.log"
|
||||
}
|
||||
else {
|
||||
|
@ -81,8 +81,14 @@ else {
|
|||
While (Test-WAUisRunning) {
|
||||
Start-Sleep 3
|
||||
}
|
||||
if (Test-Path "$WorkingDir\winget_error.txt") {
|
||||
$MessageType = "error"
|
||||
Remove-Item "$WorkingDir\winget_error.txt" -Force
|
||||
}
|
||||
else {
|
||||
$MessageType = "success"
|
||||
}
|
||||
$Message = $NotifLocale.local.outputs.output[9].message
|
||||
$MessageType = "success"
|
||||
Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss
|
||||
}
|
||||
catch {
|
||||
|
|
|
@ -108,6 +108,11 @@ if (Test-Network) {
|
|||
Write-Log "$DeletedMods Mods deleted (not externally managed) from local path: $($WAUConfig.InstallLocation)\mods" "Red"
|
||||
}
|
||||
}
|
||||
|
||||
#Delete previous winget_error if exists and System
|
||||
if (Test-Path "$WorkingDir\winget_error.txt") {
|
||||
Remove-Item "$WorkingDir\winget_error.txt" -Force
|
||||
}
|
||||
}
|
||||
|
||||
#Get White or Black list
|
||||
|
@ -129,6 +134,15 @@ if (Test-Network) {
|
|||
if ($outdated -like "Problem:*") {
|
||||
Write-Log "An error occured, exiting..." "red"
|
||||
Write-Log "$outdated" "red"
|
||||
$path = "$WorkingDir\winget_error.txt"
|
||||
New-Item "$path" -Value "$outdated" -Force
|
||||
|
||||
#Setting file rights for everyone (so that it can be deleted by 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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue