13

I often need to change the theme between Light and Dark depending on the ambient lighting condition. I cannot believe that Microsoft has not added a Light/Dark theme toggle on the Quick Actions buttons in the Action Centre (and they do not even allow third-party to create a custom button there). Other than going to "Settings -> Personalisation -> Colours -> Choose your colour", what is the easiest way to toggle the setting?

Damn Vegetables
  • 4,308
  • 19
  • 60
  • 98

1 Answers1

2

What follows is a copy/paste from this thorough answer (https://sumitkp.medium.com/how-to-enable-dark-mode-with-shortcut-on-windows-10-2571c53aed5f) referenced by Gantendo as a comment on another answer here. Please visit that link and make sure to give Sumit Jumar thanks for their good work.

=================================

Press the windows button on your keyboard, and start typing Task in the open space. Under Apps, you will see Task Scheduler, click on it.

In the Task Scheduler main window, on the left pane, click on Task Scheduler Library. Next, on the right side pane under Actions, click on Create Task…

Create Task window will be up.

Under General tab, type name and a description in fields, e.g. Name: switch_dark and Description: this will switch from dark to light. Under Security options section, tick Run only when user is logged on and Run with highest privileges options.

Under Actions tab, click New button. In Edit Action window, select Start a program under Action drop-down. Under Program/script field, type

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

and under Add arguments(optional) field, type

New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value 1 -Type Dword -Force; New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 1 -Type Dword -Force

and click OK.

Under Conditions tab, untick every option but if you are on your laptop and care about the battery usage then you may tick the option Start the task only if the computer is on AC power under Power section.

Under Settings tab, tick the following options only, Allow task to be run on demand, If the running task does not end when requested, force it to stop and click OK.

You might be prompted to enter your local account password in order to create it. If you have forgotten your password, you can reset it if you have logged in as administrator using your PIN by simply opening Command Prompt (right-click on Windows button on taskbar and click Command Prompt (Admin)) and typing net user set and press enter key.

Similarly, you will have to create another task to switch from light to dark.

Follow the above steps again, create another task, name it switch_light and put description as switches from light to Dark and keep every other setting as it is but instead in Edit Task windows under Actions tab, type

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

under Program/script field and type

New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value 0 -Type Dword -Force; New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 0 -Type Dword -Force

in Add Arguments field.

Now, we have created two tasks with names, switch_dark and switch_light. We are going to need these names in next step to create shortcuts.

On your desktop or any other folder, right-click with your mouse on open space, click New and select Shortcut.

Create Shortcut windows will pop up and under Type the location of the item, type

%SystemRoot%\System32\schtasks.exe /run /tn "switch_light"

and click Next to continue. Remember to keep the ASCII double quotes in the location or otherwise it will not work.

Under Type a name for this shortcut, any name you want, e.g. Switch To Dark Mode and click Finish to create the shortcut.

Your shortcut is now created and is on the Desktop or the folder.

Right-click on the shortcut with your mouse and select Properties.

Shortcut’s properties window will get displayed. Now, under Shortcut tab, select a shortcut key combination of your choice under Shortcut key field.

Similarly, do the above process of creating another shortcut for another task ‘switch_dark’. Instead of typing %SystemRoot%\System32\schtasks.exe /run /tn "switch_light", type

%SystemRoot%\System32\schtasks.exe /run /tn "switch_dark"

Remember to keep the ASCII double quotes in the location or otherwise it will not work.

When the shortcuts have been made, you can go an extra step to edit their Properties and assign an icon, the default collection in %SystemRoot%\System32\SHELL32.dll offers for example a silver and a golden star which can seem intuitive for dark and light modes.

Consider also using "Run: Minimized" to hide the PowerShell window while it applies the settings.

Finally, you can drag-and-drop the resulting shortcuts to your task bar, "pinning" them there, to have a quick access to switch the current Windows theme mode.

Also note that when you edit the shortcuts, a Shortcut Key combo can be assigned (be sure to not overlap with any your other programs might be using, though).

music2myear
  • 49,799