A bit of error handling in ModsProtect
parent
2471438c3b
commit
c505773f8c
|
@ -384,12 +384,15 @@ function Install-WingetAutoUpdate {
|
|||
Write-host "`nChecking Mods Directory:" -ForegroundColor Yellow
|
||||
. "$WingetUpdatePath\functions\Invoke-ModsProtect.ps1"
|
||||
$Protected = Invoke-ModsProtect "$WingetUpdatePath\mods"
|
||||
if ($Protected) {
|
||||
if ($Protected -eq $True) {
|
||||
Write-Host "The mods directory is now secured!`n" -ForegroundColor Green
|
||||
}
|
||||
elseif (!$Protected) {
|
||||
elseif ($Protected -eq $False) {
|
||||
Write-Host "The mods directory was already secured!`n" -ForegroundColor Green
|
||||
}
|
||||
else {
|
||||
Write-Host "Error: The mods directory couldn't be verified as secured!`n" -ForegroundColor Red
|
||||
}
|
||||
|
||||
#Create Shortcuts
|
||||
if ($StartMenuShortcut) {
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
#Check if Local Users have write rights in Mods directory or not (and take action if necessary):
|
||||
|
||||
function Invoke-ModsProtect ($ModsPath) {
|
||||
$directory = Get-Item -Path $ModsPath
|
||||
try {
|
||||
$directory = Get-Item -Path $ModsPath -ErrorAction SilentlyContinue
|
||||
$acl = Get-Acl -Path $directory.FullName
|
||||
#Local Users - S-1-5-32-545
|
||||
$userSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-545")
|
||||
|
@ -57,4 +58,8 @@ function Invoke-ModsProtect ($ModsPath) {
|
|||
return $True
|
||||
}
|
||||
return $False
|
||||
}
|
||||
catch {
|
||||
return "Error"
|
||||
}
|
||||
}
|
|
@ -74,12 +74,15 @@ function Invoke-PostUpdateActions {
|
|||
#Security check
|
||||
Write-Log "-> Checking Mods Directory:" "yellow"
|
||||
$Protected = Invoke-ModsProtect "$($WAUConfig.InstallLocation)\mods"
|
||||
if ($Protected) {
|
||||
if ($Protected -eq $True) {
|
||||
Write-Log "-> The mods directory is now secured!" "green"
|
||||
}
|
||||
elseif (!$Protected) {
|
||||
elseif ($Protected -eq $False) {
|
||||
Write-Log "-> The mods directory was already secured!" "green"
|
||||
}
|
||||
else {
|
||||
Write-Log "-> Error: The mods directory couldn't be verified as secured!" "red"
|
||||
}
|
||||
|
||||
#Convert about.xml if exists (previous WAU versions) to reg
|
||||
$WAUAboutPath = "$WorkingDir\config\about.xml"
|
||||
|
|
Loading…
Reference in New Issue