Customize Windows 10+ default theme
Content
- Purpose
- Study
- PowerShell script
- Sources / usefull resources
Purpose
One day, I wanted to change the default wallpaper and lockscreen of Windows computers for all the user profiles and let the users change these settings as they want. I find different ways by browsing Internet but they did not answere all my needs. My needs were the folowing:
- Set custom wallpaper
- Customize wallpaper screen
- Set lockscreen
- Allow users to change lockscreen
- Apply this to existing and/or new profiles
Study
C# code integration (wallpaper)
Technical basis
This solution relies on the Win32 API function SystemParametersInfo from user32.dll
. This script must be executed in User context or ran using ServiceUI.exe
from Microsoft Deployment Toolkit
Limitations
- Must be executed in user context
- Apply only on current user
Code snippet
|
|
Registry keys (lockscreen)
Technical basis
We can use the following registry value to customize lockscreen:
Name: LockScreenImage
Path: HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization\LockScreenImage
Type: String
Value: <path to lockscreen image>
Limitations
- No limitation found yet
Code snippet
|
|
Registry keys (theme)
Technical basis
I found that we can simply customize the default theme using the following registry values:
Name | Path | Type | Value |
---|---|---|---|
InstallTheme | HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes | String | <path to theme file> |
DesktopBackground | HKLM\SOFTWARE\\Microsoft\Windows\CurrentVersion\Themes | String | <path to background file> |
BrandIcon | HKLM\SOFTWARE\\Microsoft\Windows\CurrentVersion\Themes | String | <path to icon file> |
ThemeName | HK\SOFTWARE\LM\Microsoft\Windows\CurrentVersion\Themes | String | <THEME NAME> |
CurrentTheme | HKU\<SID>\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes | String | <path to theme file> |
Theme file:
Default theme path: C:\Windows\resources\Themes\aero.theme
|
|
In order to prevent misconfiguration, I suggest to either create a new theme file from the default file or customize the default theme file.
Limitations
- No limitation found yet
Code snippet
|
|
Applying theme to user already logged-in (optional)
Technical basis
In order to apply the theme to the current user, you can use the following code:
|
|
This code must be run in the user context, you can use KelvinTegelaar/RunAsUser or create your own system (this is what I choose)
Code snippet
|
|
Final solution
Full code here (lockscreen left as default)
Sources / usefull resources
- https://docs.microsoft.com/en-us/answers/questions/619056/powershell-to-set-second-monitor-wallpaper.html
- https://stackoverflow.com/questions/69776800/how-to-set-lock-screen-photo-using-powershell
- https://stackoverflow.com/questions/546818/how-do-i-change-the-current-windows-theme-programmatically
- https://windows10dll.nirsoft.net/themecpl_dll.html