mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 06:35:51 -06:00
33 lines
1.0 KiB
PowerShell
33 lines
1.0 KiB
PowerShell
|
Function Invoke-WPFDarkMode {
|
||
|
<#
|
||
|
|
||
|
.DESCRIPTION
|
||
|
Sets Dark Mode on or off
|
||
|
|
||
|
#>
|
||
|
Param($DarkMoveEnabled)
|
||
|
Try{
|
||
|
if ($DarkMoveEnabled -eq $false){
|
||
|
Write-Host "Enabling Dark Mode"
|
||
|
$DarkMoveValue = 0
|
||
|
}
|
||
|
else {
|
||
|
Write-Host "Disabling Dark Mode"
|
||
|
$DarkMoveValue = 1
|
||
|
}
|
||
|
|
||
|
$Theme = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
|
||
|
Set-ItemProperty -Path $Theme -Name AppsUseLightTheme -Value $DarkMoveValue
|
||
|
Set-ItemProperty -Path $Theme -Name SystemUsesLightTheme -Value $DarkMoveValue
|
||
|
}
|
||
|
Catch [System.Security.SecurityException] {
|
||
|
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
|
||
|
}
|
||
|
Catch [System.Management.Automation.ItemNotFoundException] {
|
||
|
Write-Warning $psitem.Exception.ErrorRecord
|
||
|
}
|
||
|
Catch{
|
||
|
Write-Warning "Unable to set $Name due to unhandled exception"
|
||
|
Write-Warning $psitem.Exception.StackTrace
|
||
|
}
|
||
|
}
|