Comment activer light mode/dark mode in Windows 11 programatically?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Comment activer light mode/dark mode in Windows 11 programatically?

Message par ForumBot »

J'essaie de schedule the light mode/dark mode in Windows personalization paramètres using Task scheduler, so that Windows theme colors will change based on time of day, which is également better for eyes.

These 2 clés are the seulement ones responsible for it:

```
# Set Windows Personalization, color settings, to enable Light mode for System
$RegistryPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize'
$Name = 'SystemUsesLightTheme'
$Value = '1'
If (-NOT (Test-Path $RegistryPath)) { New-Item -Path $RegistryPath -Force | Out-Null }
New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType DWORD -Force

# Set Windows Personalization, color settings, to enable Light mode for Apps
$RegistryPath = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize'
$Name = 'AppsUseLightTheme'
$Value = '1'
If (-NOT (Test-Path $RegistryPath)) { New-Item -Path $RegistryPath -Force | Out-Null }
New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType DWORD -Force

```

Running that seulement partially changes the Windows theme from dark to light, like la barre des tâches and explorateur de fichiers ne sont pas changed, but paramètres page itself and some other areas are changed.

What other component are responsible, other than registry, that perform these personalization tasks?

I've traced the paramètres processus when changing the theme and no other registry clé other than those 2 are modified.

Changing the theme using paramètres is la seule façon J'ai trouvé jusqu'à présent that performs the theme change properly.
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Comment activer light mode/dark mode in Windows 11 programatically?

Message par ForumBot »

Well, turns out I ne need le registre du tout.

Windows 11 saves the built-dans lemes in this répertoire:

```
C:\Windows\Resources\Themes

```

après checking the ACLs there, J'ai remarqué all utilisateurs have the read and execute autorisations, so no need to modify any autorisations there.

these 4 fichiers which are built-dans lemes are important,

- themeA.theme

- themeB.theme

- themeC.theme

- themeD.theme

the first 2 are dark mode, the other 2 are light mode

so just créé 4 task schedules via PowerShell so that the first 2 dark themes sera used from 6PM till 8:59AM, and from 9AM to 5:59PM the Light themes sera used.

```
# Task Schedules

$user = "ENTER YOUR USERNAME"

# Dark Theme A
$action = New-ScheduledTaskAction -Execute "C:\Windows\Resources\Themes\themeA.theme"

$trigger = New-ScheduledTaskTrigger -Daily -At 6PM
Register-ScheduledTask -Action $action -Trigger $trigger -TaskPath "Theme Scheduling" -TaskName "Dark ThemeA" -Description "Activates Dark Theme everyday at 6PM" -User $user -RunLevel Limited

# Dark Theme B

$action = New-ScheduledTaskAction -Execute "C:\Windows\Resources\Themes\themeB.theme"

$trigger = New-ScheduledTaskTrigger -Daily -At 12AM
Register-ScheduledTask -Action $action -Trigger $trigger -TaskPath "Theme Scheduling" -TaskName "Dark ThemeB" -Description "Activates Dark Theme everyday at 12AM" -User $user -RunLevel Limited

# Light Theme C

$action = New-ScheduledTaskAction -Execute "C:\Windows\Resources\Themes\themeC.theme"

$trigger = New-ScheduledTaskTrigger -Daily -At 9AM
Register-ScheduledTask -Action $action -Trigger $trigger -TaskPath "Theme Scheduling" -TaskName "Light ThemeC" -Description "Activates Light Theme everyday at 9AM" -User $user -RunLevel Limited



# Light Theme D

$action = New-ScheduledTaskAction -Execute "C:\Windows\Resources\Themes\themeD.theme"

$trigger = New-ScheduledTaskTrigger -Daily -At 2PM
Register-ScheduledTask -Action $action -Trigger $trigger -TaskPath "Theme Scheduling" -TaskName "Light ThemeD" -Description "Activates Light Theme everyday at 2PM" -User $user -RunLevel Limited

```

The reason I wanted to do c'est parce que c'est the smart way to have the OS change themes based on time of day, également better for eyes.

c'est également one du [top feedback items in the Feedback Hub](https://aka.ms/AA98751) that people voted for, Je pense Microsoft will eventually implement this fonctionnalité, but until ensuite, use the PowerShell script above.
Répondre

Revenir à « Windows 11 »