sodcalculator

10 Tech How-To

Auto Toggle Dark & Light Mode on Windows 10

Guide 10-29405 · Updated · Step by step

Windows 10 doesn’t have a built-in scheduler for switching between dark and light themes, but you can automate the toggle using Task Scheduler and a simple PowerShell script. This guide shows you how to set it up so your system automatically switches to dark mode at night and light mode in the morning, reducing eye strain and matching your environment.

What You’ll Need

  • Windows 10 (version 1809 or later recommended, as earlier versions may lack some registry keys)
  • Administrator access to create scheduled tasks
  • Basic comfort with editing text files (Notepad is fine)

Step-by-Step

  1. Create the PowerShell script. Open Notepad and paste the following script. This script toggles both the app mode and system mode (taskbar and title bars) by modifying registry values.
  2. # ToggleDarkLight.ps1
    param([string]$Mode = "dark")
    
    $appsKey = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
    $systemKey = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
    
    if ($Mode -eq "dark") {
        Set-ItemProperty -Path $appsKey -Name AppsUseLightTheme -Value 0
        Set-ItemProperty -Path $systemKey -Name SystemUsesLightTheme -Value 0
    } else {
        Set-ItemProperty -Path $appsKey -Name AppsUseLightTheme -Value 1
        Set-ItemProperty -Path $systemKey -Name SystemUsesLightTheme -Value 1
    }
  3. Save the script. Save the file as ToggleDarkLight.ps1 in a folder you won’t delete, e.g., C:\Scripts\. Make sure the “Save as type” is set to “All Files” to avoid a .txt extension.
  4. Open Task Scheduler. Press Win, type “Task Scheduler”, and open it. You’ll need administrator rights; click “Yes” if prompted.
  5. Create a new task. In the right-hand pane, click “Create Task…” (not “Create Basic Task”).
  6. General tab settings. Give the task a name like “Dark Mode at Night”. Check “Run whether user is logged on or not” and “Run with highest privileges”. Under “Configure for”, select “Windows 10”.
  7. Set the trigger. Go to the “Triggers” tab, click “New…”. Set “Begin the task” to “On a schedule”. Choose “Daily” and set the start time to your desired dark mode time (e.g., 7:00 PM). Click OK.
  8. Set the action. Go to the “Actions” tab, click “New…”. In “Action”, select “Start a program”. In “Program/script”, type powershell.exe. In “Add arguments”, type: -ExecutionPolicy Bypass -File "C:\Scripts\ToggleDarkLight.ps1" -Mode dark (adjust the path to your script). Click OK.
  9. Create the light mode task. Repeat steps 4-7, but name it “Light Mode at Morning”, set the trigger time to your desired light mode time (e.g., 7:00 AM), and in the arguments use -Mode light.
  10. Test the tasks. Right-click each task in the Task Scheduler Library and select “Run”. Check if the theme changes immediately. If not, proceed to Troubleshooting.

Common Mistakes

  • Wrong registry path: Using HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize is correct; a common mistake is omitting the CurrentVersion part.
  • Forgetting the -Mode argument: If you omit it, the script defaults to dark, so your light task won’t work.
  • Saving the script with .txt extension: Windows may append .txt if you don’t change “Save as type”. This causes the script to not execute.
  • Not using absolute paths: Relative paths in the action may break if the working directory changes. Always use full paths.

Tips

  • Use the same script for both tasks: This reduces duplication and makes updates easier.
  • Schedule a “wake” trigger: If your PC sleeps during the transition, add a trigger to run the task when the computer wakes (in the trigger settings, check “Wake the computer to run this task”).
  • Test with a short delay: Temporarily set the trigger to 2 minutes from now to verify the task works before setting your final times.
  • Consider using a third-party tool: If you prefer not to script, apps like Auto Dark Mode offer a GUI, but the script method is free and built-in.

Troubleshooting

  • Task runs but theme doesn’t change: Check if the script runs manually (right-click task > Run). If it works manually, check the task’s “Conditions” tab – uncheck “Start the task only if the computer is on AC power” if you’re on a laptop.
  • PowerShell execution policy error: If you see “cannot be loaded because running scripts is disabled”, ensure you used the -ExecutionPolicy Bypass argument. Alternatively, set the policy permanently with Set-ExecutionPolicy RemoteSigned in an admin PowerShell.
  • Task doesn’t run at all: Check the “History” tab in Task Scheduler to see if the task ran and what the last result code was. A code like 0x2 means the file path is wrong.
  • Only apps change, not the taskbar: Some Windows builds have separate registry keys for apps and system. The script above sets both, but if your system doesn’t respond, try restarting Explorer (via Task Manager) after a manual run.
  • Changes revert after reboot: This is rare, but ensure the tasks are set to “Run whether user is logged on or not” and that the user account has permission to modify the registry.

Frequently Asked Questions

Does this work on Windows 11?

This guide is for Windows 10. Windows 11 has a similar registry structure, but the task scheduler steps are the same. However, Windows 11 also has native scheduling in Settings > Personalization > Colors, so you may not need this script.

Can I set different times for weekdays and weekends?

Yes, create separate tasks for each schedule, or use a single task with multiple triggers (one for weekdays, one for weekends) and adjust the start times accordingly.

Will this affect all apps?

It affects apps that respect the Windows theme setting. Some apps (like older ones) have their own dark mode and won’t change.

Is it safe to edit the registry?

Yes, the script changes only two values that Windows itself uses for theme settings. It’s reversible by running the script with the opposite mode or manually changing the theme in Settings.

Can I use this to toggle a specific app’s dark mode?

No, this script only toggles the Windows system theme. Individual apps need their own settings or scripts.

What if I want to switch manually without a script?

You can still use keyboard shortcuts or a desktop shortcut, but the script is the simplest way to automate it. For manual toggling, you can also create a shortcut to the PowerShell command with the appropriate argument.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →