Reworked DelRegKey() error messages

This commit is contained in:
Yorick Barbanneau 2018-03-26 12:35:40 +02:00
parent 4ba4ef330a
commit ade08ccca0

View file

@ -217,7 +217,7 @@ function DelRegKey {
) )
Write-Host -NoNewline "`tDelete registery key $($params.key) : " Write-Host -NoNewline "`tDelete registery key $($params.key) : "
if ( ! (Test-Path $params.path) ){ if ( ! (Test-Path $params.path) ){
Write-Host -ForegroundColor Red " Error path not found" Write-Host -ForegroundColor Red " Error (path not found)"
return return
} }
try { try {
@ -225,12 +225,11 @@ function DelRegKey {
Write-host -ForegroundColor Green "done" Write-host -ForegroundColor Green "done"
} }
catch [System.Security.SecurityException]{ catch [System.Security.SecurityException]{
Write-Host -ForegroundColor Red "Error in DelRegKey`n`t" Write-Host -ForegroundColor Red "Error (access denied)"
Write-Host -ForegoundColor DarkRed "Access to $($params.path)\$($params.key) denied"
} }
catch { catch {
Write-Host -ForegroundColor Red -NoNewLine "Error in DelRegKey`n`t" Write-Host -ForegroundColor Red -NoNewLine "Error`n`t"
Write-Host -ForegoundColor DarkRed $Error[0].Exception.Message Write-Host -ForegroundColor DarkRed $Error[0].Exception.Message
} }
} }