mirror of
https://github.com/Yamato-Security/WELA.git
synced 2026-03-25 22:12:43 +01:00
fix: optimize registry path checks in WELA.ps1
This commit is contained in:
9
WELA.ps1
9
WELA.ps1
@@ -5522,7 +5522,8 @@ function Set-RegistryConfig {
|
||||
foreach ($reg in $RegPaths) {
|
||||
try {
|
||||
$currentValue = "Not Set"
|
||||
if (Test-Path $reg.Path) {
|
||||
$pathExists = Test-Path $reg.Path
|
||||
if ($pathExists) {
|
||||
$prop = Get-ItemProperty -Path $reg.Path -Name $reg.Name -ErrorAction SilentlyContinue
|
||||
if ($prop) {
|
||||
$currentValue = $prop.$($reg.Name)
|
||||
@@ -5540,7 +5541,9 @@ function Set-RegistryConfig {
|
||||
$response = Read-Host "Your current setting is $currentValue. Do you want to change it to $( $reg.Value )? (Y/n)"
|
||||
}
|
||||
if ($response -eq "" -or $response -eq "Y" -or $response -eq "y") {
|
||||
New-Item -Path $reg.Path -Force | Out-Null
|
||||
if (-not $pathExists) {
|
||||
New-Item -Path $reg.Path -Force | Out-Null
|
||||
}
|
||||
Set-ItemProperty -Path $reg.Path -Name $reg.Name -Value $reg.Value -Type DWord
|
||||
Write-Host "[OK] Set $($reg.Name)" -ForegroundColor Green
|
||||
} else {
|
||||
@@ -6063,4 +6066,4 @@ switch ($Cmd.ToLower()) {
|
||||
Write-Host "Invalid command. Use 'help' to see available commands."
|
||||
Write-Host $usage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user