Windows 10: Switch between dark mode and light mode through Powershell scripts with icons for them in Taskbar
Given below are notes I had made in June 2024 for my solution to have two Powershell scripts to switch to light mode or dark mode in Windows 10, and have shortcuts for these scripts pinned to Taskbar with suitable icons. I have used them for 6 months now without any issues. Further, I was able to replicate the method using these notes on a fallback mini Laptop with Windows 10 that I am using nowadays (since my main desktop PC has stopped working).
PS command to enable dark mode
New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value 0 -Type Dword -Force
PS command to remove dark mode (and so use light mode)
Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme
Ref: Instantly switch between dark and light mode for Windows, https://stackoverflow.com/questions/77179391/instantly-switch-between-dark-and-light-mode-for-windows
----
To run shortcuts of PS script files (e.g. godark.ps1) with above commands (1 command in 1 script), I modified Target Shortcut property to "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file D:\Users\Ravi-user\cmds\godark.ps1" for godark.ps1 script. [I only typed in: powershell.exe -file D:\Users\Ravi-user\cmds\godark.ps1 in the dialog. I think Windows expanded it automatically.]
Ref:
PowerShell Scripting - Run a Script from Shortcut, https://www.tenforums.com/tutorials/97162-powershell-scripting-run-script-shortcut.html
Got icons8-dark-theme-30.png and icons8-light-mode-78.png free icons from https://icons8.com/ . Converted them to Windows icons icons8-dark-theme-30.ico and icons8-light-mode-78.ico for free using https://www.zamzar.com/convert/png-to-ico/
Associated icons with the shortcuts.
Then I dragged the shortcuts to taskbar which provided me option to pin them to taskbar which I did.
Now I have two icons in taskbar which I can click to go to light mode or dark mode.
Comments
Post a Comment