I am building a custom Windows 10 media PC for church that will display a color scheme and background corresponding to the liturgical color for the service. One computer will act as a server and calculate the appropriate color based on the liturgical calendar and any church events.
The goal is to save themes for each color while configuring the system. However, I am having difficulty finding an automated way to change the entire theme (not just the background) on login and periodically throughout the day without requiring administrative privileges.
Since the PC will be used by individuals without significant computer knowledge, it is important to follow best practices and limit the main account to user-level privileges with only a few select administrators from the congregation staff/volunteers.
I have reviewed previous relevant work, but much of it is outdated. The “Location based windows theme” solution only changes the screensaver, while the “Windows Color Scheme (Theme) Program” requires user action and offers more UI customization than desired, which may confuse users.
The “Automatically recognize desktop background image has changed” solution requires administrative privileges and may not be suitable.
To solve this problem, I have developed the following pseudocode:
Sub onUserLogin()
{
coordinateLiturgicalColor(); ' Check (and set) current color
bindTimerEvent(); ' Set timer to fire subroutine at x:00 and x:30
}
Sub coordinateLiturgicalColor()
{
currentColor = currentTheme.name();
newColor = getColor("https://192.168.1.200/color.php");
if (currentColor != newColor)
{
currentTheme.name = newColor;
currentTheme.refresh();
}
}
3 Answers
Changing User Account Windows Themes
Customizing the Windows theme is a great way to personalize your desktop and make it look unique. However, changing the theme for all user accounts on a PC can be a daunting task. In this blog post, we will discuss how to change the user account Windows themes using a pseudocode approach.
Background
The Windows operating system comes with several built-in themes that users can choose from. These themes include a set of wallpapers, color schemes, and sounds that give the desktop a consistent look and feel. While the default themes are good enough for most users, some may want to create their own custom themes.
When it comes to changing the Windows theme, users can do it via the Personalization settings, which is accessible from the Settings app or the Control Panel. However, changing the theme for all user accounts on a PC requires administrative privileges, which may not be ideal in some scenarios.
For instance, in the case of a church media PC that displays a color scheme and background corresponding to the liturgical color for the service, changing the theme for all user accounts may not be feasible. In such cases, it is better to automate the process using a script or program.
The Challenge
The challenge of changing the user account Windows themes automatically is to do it without requiring administrative privileges and without confusing the users. Since the PC will be used by individuals without significant computer knowledge, it is important to follow best practices and limit the main account to user-level privileges with only a few select administrators from the congregation staff/volunteers.
Previous solutions, such as the “Location based windows theme” and “Windows Color Scheme (Theme) Program,” have limitations that make them unsuitable for this scenario. The former only changes the screensaver, while the latter requires user action and offers more UI customization than desired, which may confuse users.
Another solution, the “Automatically recognize desktop background image has changed,” requires administrative privileges and may not be suitable for non-administrative users.
The Solution
To solve this problem, we can use a pseudocode approach that involves running a script or program on user login. The script will check the current liturgical color, retrieve the appropriate color scheme from a remote server, and apply it to the current user account. The script will also set a timer to fire periodically, say every 30 minutes, to check if the color scheme has changed and apply it if necessary.
Here’s the pseudocode:
Sub onUserLogin()
{
coordinateLiturgicalColor(); ' Check (and set) current color
bindTimerEvent(); ' Set timer to fire subroutine at x:00 and x:30
}
Sub coordinateLiturgicalColor()
{
currentColor = currentTheme.name();
newColor = getColor("https://192.168.1.200/color.php");
if (currentColor != newColor)
{
currentTheme.name = newColor;
currentTheme.refresh();
}
}
The pseudocode defines two subroutines: onUserLogin and coordinateLiturgicalColor. The onUserLogin subroutine runs when a user logs in and coordinates the liturgical color and timer events. The coordinateLiturgicalColor subroutine checks the current color scheme and retrieves the appropriate color scheme from a remote server. If the color scheme has changed, it applies the new color scheme to the current user account.
The getColor function retrieves the appropriate color scheme from the remote server using a URL, say https://192.168.1.200/color.php. The color.php script on the server will calculate the appropriate color based on the liturgical calendar and any church events and return it to the client.
Implementation
To implement the pseudocode, we need to write a script or program that can run on user login and coordinate the liturgical color and timer events. We can use a scripting language such as PowerShell or a programming language such as C# or Python to write the script or program.
The script or program should be installed on the church media PC and set to run automatically on user login. It should also be configured to run with user-level privileges and not require administrative privileges.
Here’s a PowerShell script that implements the pseudocode:
$timer = New-Object System.Timers.Timer
$timer.Interval = 1800000 # 30 minutes
$timer.AutoReset = $true
$timer.Enabled = $true
$currentTheme = (Get-ItemProperty -Path "HKCU:SoftwareMicrosoftWindowsCurrentVersionThemes" -Name "CurrentTheme").CurrentTheme
$currentColor = ($currentTheme -split '\' | Select-Object -Last 1) -replace '.theme$'
function coordinateLiturgicalColor()
{
$newColor = Invoke-WebRequest -Uri "https://192.168.1.200/color.php" -UseBasicParsing | Select-Object -ExpandProperty Content
if ($currentColor -ne $newColor)
{
$newTheme = "C:WindowsResourcesThemes$newColor.theme"
Set-ItemProperty -Path "HKCU:SoftwareMicrosoftWindowsCurrentVersionThemes" -Name "CurrentTheme" -Value $newTheme
rundll32.exe user32.dll, UpdatePerUserSystemParameters
$currentColor = $newColor
}
}
function onTimerElapsed($sender, $eventArgs)
{
coordinateLiturgicalColor
}
function onLogon($eventData)
{
coordinateLiturgicalColor
$timer.add_Elapsed({onTimerElapsed})
}
Register-ObjectEvent -InputObject ([System.Diagnostics.EventLog]::new("System")) -EventName "Logon" -Action {onLogon($Event)} | Out-Null
The PowerShell script defines four functions: coordinateLiturgicalColor, onTimerElapsed, onLogon, and a main function that sets up the timer and event handlers.
The coordinateLiturgicalColor function checks the current color scheme and retrieves the appropriate color scheme from the remote server. If the color scheme has changed, it applies the new color scheme to the current user account.
The onTimerElapsed function is called when the timer elapses and coordinates the liturgical color.
The onLogon function is called when a user logs on and coordinates the liturgical color and timer events.
The main function sets up the timer and event handlers and registers the script to run automatically on user login.
Conclusion
Changing the user account Windows themes automatically can be a challenging task, especially when it comes to doing it without requiring administrative privileges and without confusing the users. However, by using a pseudocode approach, we can automate the process and make it easier for non-administrative users.
In this blog post, we discussed how to change the user account Windows themes using a pseudocode approach and provided a PowerShell script that implements the pseudocode. With this approach, churches and other organizations can display a color scheme and background corresponding to the liturgical color for the service without requiring administrative privileges and confusing the users.
It looks like you have a good start on a solution for changing the theme on login and periodically throughout the day. Here are a few additional suggestions to consider:
- To change the entire theme (including the color scheme, desktop background, and window border), you can use the
SetWindowTheme
function in theUxTheme.dll
library. You can call this function using theDllImport
attribute in C# or by using theDeclare
statement in VBA. - To avoid requiring administrative privileges, you can set the theme file to be stored in a location that the user account has access to, such as the user’s profile directory.
- To avoid confusing users with UI customization options, you can create a simple interface for selecting the desired theme. This could be as simple as a dropdown menu with the available themes listed.
- If you want to change the theme automatically based on the liturgical calendar, you can use the
System.Net.WebClient
class to download the current color from a web server. You can then parse the response to determine the current color and apply the corresponding theme. - To set a timer to fire a subroutine at specific intervals, you can use the
System.Timers.Timer
class in C# or theWindows.Forms.Timer
control in VBA.
I hope these suggestions are helpful! Let me know if you have any other questions or need further assistance.
To customize the appearance of your Windows desktop, you can use .theme files. These files can be executed to change various aspects of the desktop’s appearance, including colors. A benefit of using .theme files is that they can be installed by any user without requiring administrator privileges.
You can create and edit .theme files on your own computer. Changes you make to a .theme file will be saved in the file located at
C:\Users\USERNAME\AppData\Local\Microsoft\Windows\Themes\Custom.theme
Alternatively, you can save the .theme file under a different name.
To make the .theme files available to other users, you can copy them to a network share on your computer or a central server. Then, using the Task Scheduler, you can set up tasks that will automatically install the .theme file at a specified time, such as once per day or hour.
In addition to customizing the appearance of the desktop through .theme files, you can also choose between a Light or Dark theme color for the Default App Mode. This setting is stored in the registry at the following key:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize
, in a value called AppsUseLightTheme (DWORD). A value of 0 corresponds to the Dark theme, while a value of 1 corresponds to the Light theme. It is unclear whether modifying this setting requires a restart of Explorer or a logout and login.
To set the Default App Mode to Light theme, you can use the following .reg file:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize]
"AppsUseLightTheme"=dword:00000001