How to change theme in Windows 7 with Powershell script?

Posted by Greg McGuffey on Super User See other posts from Super User or by Greg McGuffey
Published on 2011-11-29T05:34:15Z Indexed on 2012/06/11 10:42 UTC
Read the original article Hit count: 260

Filed under:
|
|

I would like to have a script that would change the current theme of Windows 7. I found the registry entry where this stored, but I apparently need to take some further action to get windows to load the theme. Any ideas?

Here is the script that I'm trying to use, but isn't working (registry updated, but theme not changed):

######################################
# Change theme by updating registry. #
######################################

# Define argument which defines which theme to apply. 
param ( [string] $theme = $(Read-Host -prompt "Theme") )

# Define the themes we know about.
$knownThemes = @{ "myTheme" = "mytheme.theme"; "alien" = "oem.theme" }

# Identify paths to user themes.
$userThemes = " C:\Users\yoda\AppData\Local\Microsoft\Windows\"

# Get name of theme file, based on theme provided
$themeFile = $knownThemes["$theme"]

# Build path to theme and set registry.
$newThemePath = "$userThemes$themeFile"
$regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\"
Set-ItemProperty -path $regPath -name CurrentTheme -value $newThemePath

# Update system with this info...this isn't working!
rundll32.exe user32.dll, UpdatePerUserSystemParameters

Thanks!

© Super User or respective owner

Related posts about windows-7

Related posts about powershell