mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 22:55:52 -06:00
add a lot of error handling
This commit is contained in:
parent
5c2d5fae1e
commit
a4fccd3c85
@ -19,25 +19,32 @@ Function Get-WinUtilToggleStatus {
|
|||||||
if (($ToggleSwitchReg.path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {
|
if (($ToggleSwitchReg.path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {
|
||||||
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
|
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
|
||||||
write-host "Created HKU drive"
|
write-host "Created HKU drive"
|
||||||
|
if (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue) {
|
||||||
|
Write-Host "HKU drive created successfully" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host "Failed to create HKU drive"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ToggleSwitchReg) {
|
if ($ToggleSwitchReg) {
|
||||||
$count = 0
|
$count = 0
|
||||||
|
|
||||||
foreach ($regentry in $ToggleSwitchReg) {
|
foreach ($regentry in $ToggleSwitchReg) {
|
||||||
$regstate = (Get-ItemProperty -path $($regentry.Path)).$($regentry.Name)
|
write-host "Checking $($regentry.path)"
|
||||||
|
$regstate = (Get-ItemProperty -path $regentry.Path).$($regentry.Name)
|
||||||
if ($regstate -eq $regentry.Value) {
|
if ($regstate -eq $regentry.Value) {
|
||||||
$count += 1
|
$count += 1
|
||||||
|
write-host "$($regentry.Name) is true (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))" -ForegroundColor Green
|
||||||
} else {
|
} else {
|
||||||
write-debug "$($regentry.Name) is false (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))"
|
write-host "$($regentry.Name) is false (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($count -eq $ToggleSwitchReg.Count) {
|
if ($count -eq $ToggleSwitchReg.Count) {
|
||||||
write-debug "$($ToggleSwitchReg.Name) is true (count: $count)"
|
write-host "$($ToggleSwitchReg.Name) is true (count: $count)" -ForegroundColor Green
|
||||||
return $true
|
return $true
|
||||||
} else {
|
} else {
|
||||||
write-debug "$($ToggleSwitchReg.Name) is false (count: $count)"
|
write-host "$($ToggleSwitchReg.Name) is false (count: $count)"
|
||||||
return $false
|
return $false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -77,9 +77,14 @@ function Invoke-WinUtilTweaks {
|
|||||||
if($sync.configs.tweaks.$CheckBox.registry) {
|
if($sync.configs.tweaks.$CheckBox.registry) {
|
||||||
$sync.configs.tweaks.$CheckBox.registry | ForEach-Object {
|
$sync.configs.tweaks.$CheckBox.registry | ForEach-Object {
|
||||||
Write-Debug "$($psitem.Name) and state is $($psitem.$($values.registry))"
|
Write-Debug "$($psitem.Name) and state is $($psitem.$($values.registry))"
|
||||||
if (($psitem.Path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {
|
if (($ToggleSwitchReg.path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {
|
||||||
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
|
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
|
||||||
write-host "Created HKU drive"
|
write-host "Created HKU drive"
|
||||||
|
if (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue) {
|
||||||
|
Write-Host "HKU drive created successfully"
|
||||||
|
} else {
|
||||||
|
Write-Host "Failed to create HKU drive"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry)
|
Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry)
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,13 @@ function Invoke-WPFUIElements {
|
|||||||
|
|
||||||
$sync[$entryInfo.Name] = $checkBox
|
$sync[$entryInfo.Name] = $checkBox
|
||||||
|
|
||||||
$sync[$entryInfo.Name].IsChecked = Get-WinUtilToggleStatus $entryInfo.Name
|
$sync[$entryInfo.Name].IsChecked = (Get-WinUtilToggleStatus $entryInfo.Name)
|
||||||
|
|
||||||
|
if ($sync[$entryInfo.Name].IsChecked) {
|
||||||
|
write-host "$($entryInfo.Name) is checked" -ForegroundColor Blue
|
||||||
|
} else {
|
||||||
|
write-host "$($entryInfo.Name) is not checked" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
|
||||||
$sync[$entryInfo.Name].Add_Checked({
|
$sync[$entryInfo.Name].Add_Checked({
|
||||||
[System.Object]$Sender = $args[0]
|
[System.Object]$Sender = $args[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user