Puvox – Blog

Programmatically change Windows Theme from-to DARK/LIGHT

There are several ways:

==== Method 1 ====

Right click on desktop, select New > Shortcut > type ms-settings:personalization-colors. Then open it anytime.

NOTE: To sync VSCODE theme (dark/light) to OS theme, open User Preferencesin VSCODE, then search & enable autoDetectColorScheme.

 

==== Method 2 ====

Save this snippet in “theme-changer.ps1” file, and right-click > “Run with Powershell”

Add-Type -AssemblyName PresentationFramework
$result = [System.Windows.MessageBox]::Show("Enable Dark Mode?", "Confirmation", "YesNoCancel", "Question")
if ($result -eq "Yes") {
    Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUsesLightTheme -Value 0 -Type Dword -Force
    Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value 0 -Type Dword -Force
} elseif ($result -eq "No") {
    Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUsesLightTheme -Value 1 -Type Dword -Force
    Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value 1 -Type Dword -Force
} else {
    Write-Host "canceled"
}
# if changes does not take effect immediately, either click "Start" button, or add this line below: taskkill /f /im explorer.exe && start explorer.exe

 

==== Method 3 ====

Open : %LocalAppData%\Microsoft\Windows\Themes  , copy the file from there to desktop and name it “Darkmode”, and change the inside content(in Notepad) of “AppMode” and “SystemMode” from Dark ,  then do similarly for Light. Finished! click any of the file on your desktop

==== Method 4 ====

How do I change the current Windows theme programmatically? – Stack Overflow

 

Exit mobile version