-
Notifications
You must be signed in to change notification settings - Fork 0
/
win-scheduled-tasks_dark-mode-toggle.ps1
85 lines (69 loc) · 3.05 KB
/
win-scheduled-tasks_dark-mode-toggle.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<#
.DESCRIPTION
Creates four scheduled tasks to switch between light and dark modes at specific times.
#>
<#
.NOTES
References:
https://www.howtogeek.com/356087/how-to-automatically-enable-windows-10s-dark-theme-at-night/
https://www.windowscentral.com/how-switch-between-light-and-dark-colors-schedule-automatically-windows-10
https://superuser.com/a/1590444
#>
$settings = New-ScheduledTaskSettingsSet `
-AllowStartIfOnBatteries `
-DontStopIfGoingOnBatteries `
-StartWhenAvailable `
# Enable Dark mode for apps at 7pm daily:
$trigger = New-ScheduledTaskTrigger `
-Daily `
-At 7pm
$action = New-ScheduledTaskAction `
-Execute 'reg.exe' `
-Argument 'add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize /v AppsUseLightTheme /t REG_DWORD /d 0 /f'
Register-ScheduledTask `
-Action $action `
-Trigger $trigger `
-TaskPath "\My custom tasks" `
-TaskName "Enable Dark mode for apps" `
-Description "Enable Dark mode for apps at 7pm daily" `
-Settings $settings
Write-Host "Created scheduled task to enable Dark mode for apps at 7pm daily." -ForegroundColor Green
# Enable Dark mode for system (Windows) at 7pm daily:
$action = New-ScheduledTaskAction `
-Execute 'reg.exe' `
-Argument 'add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize /v SystemUsesLightTheme /t REG_DWORD /d 0 /f'
Register-ScheduledTask `
-Action $action `
-Trigger $trigger `
-TaskPath "\My custom tasks" `
-TaskName "Enable Dark mode for system" `
-Description "Enable Dark mode for system (Windows) at 7pm daily" `
-Settings $settings
Write-Host "Created scheduled task to enable Dark mode for system (Windows) at 7pm daily." -ForegroundColor Green
# Disable Dark mode for apps at 7am daily:
$trigger = New-ScheduledTaskTrigger `
-Daily `
-At 7am
$action = New-ScheduledTaskAction `
-Execute 'reg.exe' `
-Argument 'add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize /v AppsUseLightTheme /t REG_DWORD /d 1 /f'
Register-ScheduledTask `
-Action $action `
-Trigger $trigger `
-TaskPath "\My custom tasks" `
-TaskName "Disable Dark mode for apps" `
-Description "Disable Dark mode for apps at 7am daily" `
-Settings $settings
Write-Host "Created scheduled task to disable Dark mode for apps at 7am daily." -ForegroundColor Green
# Disable Dark mode for system (Windows) at 7am daily:
$action = New-ScheduledTaskAction `
-Execute 'reg.exe' `
-Argument 'add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize /v SystemUsesLightTheme /t REG_DWORD /d 1 /f'
Register-ScheduledTask `
-Action $action `
-Trigger $trigger `
-TaskPath "\My custom tasks" `
-TaskName "Disable Dark mode for system" `
-Description "Disable Dark mode for system (Windows) at 7am daily" `
-Settings $settings
Write-Host "Created scheduled task to disable Dark mode for system (Windows) at 7am daily." -ForegroundColor Green