Handling both System/User now
parent
3a7694f9e2
commit
7c0c9dcb30
|
@ -81,10 +81,16 @@ else {
|
||||||
While (Test-WAUisRunning) {
|
While (Test-WAUisRunning) {
|
||||||
Start-Sleep 3
|
Start-Sleep 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#Test if there was a winget error as System/User
|
||||||
if (Test-Path "$WorkingDir\winget_error.txt") {
|
if (Test-Path "$WorkingDir\winget_error.txt") {
|
||||||
$MessageType = "error"
|
$MessageType = "error"
|
||||||
Remove-Item "$WorkingDir\winget_error.txt" -Force
|
Remove-Item "$WorkingDir\winget_error.txt" -Force
|
||||||
}
|
}
|
||||||
|
elseif (Test-Path "${env:TEMP}\winget_error.txt") {
|
||||||
|
$MessageType = "error"
|
||||||
|
Remove-Item "${env:TEMP}\winget_error.txt" -Force
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
$MessageType = "success"
|
$MessageType = "success"
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,11 +108,14 @@ if (Test-Network) {
|
||||||
Write-Log "$DeletedMods Mods deleted (not externally managed) from local path: $($WAUConfig.InstallLocation)\mods" "Red"
|
Write-Log "$DeletedMods Mods deleted (not externally managed) from local path: $($WAUConfig.InstallLocation)\mods" "Red"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#Delete previous winget_error if exists and System
|
#Delete previous winget_error (if exists) as System/User
|
||||||
if (Test-Path "$WorkingDir\winget_error.txt") {
|
if ($IsSystem -and (Test-Path "$WorkingDir\winget_error.txt")) {
|
||||||
Remove-Item "$WorkingDir\winget_error.txt" -Force
|
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
|
||||||
|
@ -130,14 +133,14 @@ if (Test-Network) {
|
||||||
Write-Log "Checking application updates on Winget Repository..." "yellow"
|
Write-Log "Checking application updates on Winget Repository..." "yellow"
|
||||||
$outdated = Get-WingetOutdatedApps
|
$outdated = Get-WingetOutdatedApps
|
||||||
|
|
||||||
#If something is wrong with the winget source, exit
|
#If something is wrong with the winget source, exit as System/User
|
||||||
if ($outdated -like "Problem:*") {
|
if ($IsSystem -and $outdated -like "Problem:*") {
|
||||||
Write-Log "An error occured, exiting..." "red"
|
Write-Log "An error occured, exiting..." "red"
|
||||||
Write-Log "$outdated" "red"
|
Write-Log "$outdated" "red"
|
||||||
$path = "$WorkingDir\winget_error.txt"
|
$path = "$WorkingDir\winget_error.txt"
|
||||||
New-Item "$path" -Value "$outdated" -Force
|
New-Item "$path" -Value "$outdated" -Force
|
||||||
|
|
||||||
#Setting file rights for everyone (so that it can be deleted by User-Run.ps1)
|
#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')
|
$rule= New-Object System.Security.AccessControl.FileSystemAccessRule ('Everyone', 'FullControl', 'Allow')
|
||||||
$acl = Get-ACL $path
|
$acl = Get-ACL $path
|
||||||
$acl.SetAccessRule($rule)
|
$acl.SetAccessRule($rule)
|
||||||
|
@ -145,6 +148,14 @@ if (Test-Network) {
|
||||||
|
|
||||||
Exit 1
|
Exit 1
|
||||||
}
|
}
|
||||||
|
elseif (!$IsSystem -and $outdated -like "Problem:*") {
|
||||||
|
Write-Log "An error occured, exiting..." "red"
|
||||||
|
Write-Log "$outdated" "red"
|
||||||
|
$path = "${env:TEMP}\winget_error.txt"
|
||||||
|
New-Item "$path" -Value "$outdated" -Force
|
||||||
|
|
||||||
|
Exit 1
|
||||||
|
}
|
||||||
|
|
||||||
#Log list of app to update
|
#Log list of app to update
|
||||||
foreach ($app in $outdated) {
|
foreach ($app in $outdated) {
|
||||||
|
|
Loading…
Reference in New Issue