PowerShell: Set Dark Theme

By Xah Lee. Date: . Last updated: .

Using PowerShell to set dark theme.

# set system pref to dark theme
sp HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 0
# set system pref to light theme
sp HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 1
function xah-toggle-darktheme {
# .DESCRIPTION
# Toggle dark theme
# Version 2022-01-15
# .LINK
# http://xahlee.info/powershell/powershell_set_darktheme.html
$xPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize";
$xname = "AppsUseLightTheme"
if ((gp $xPath -Name AppsUseLightTheme).$xname -eq 1) {
sp $xPath -Name $xname -Value 0 }
else {
sp $xPath -Name $xname -Value 1 } }

PowerShell

How-to

Advanced

Script Examples