If you need to change individual appearance options (like window colors), you can modify the appropriate registry values under the HKEY_CURRENT_USER\Control Panel\Appearance
and HKEY_CURRENT_USER\Control Panel\Colors
keys. For example, this code will chamge the window background color to cream:
Set oShell = CreateObject("WScript.Shell")
oShell.RegWrite path & "HKCU\Control Panel\Colors\Window", "255 251 240", "REG_SZ"
Note, however, that Windows will probably apply the registry changes only after reboot.
If you need to load a ready .theme file, you can use the following code:
Const Theme = "C:\MyTheme.theme"
Set oShellApp = CreateObject("Shell.Application")
oShellApp.ControlPanelItem "desk.cpl desk,@Themes /Action:OpenTheme /file:""" & Theme & """"
Although, as sascha has pointed out, this will only bring up the Display Properties dialog with the specified theme selected; you still need the user to click OK or press Enter. It's possible to simulate key presses from script code using the WshShell.SendKeys
method:
Set oShell = CreateObject("WScript.Shell")
' Wait until the Display Properties dialog is opened
While Not oShell.AppActivate("Display Properties")
WScript.Sleep 500
Wend
' Send the Enter key to close the dialog and apply the theme
Do
oShell.SendKeys "~"
WScript.Sleep 500
Loop While oShell.AppActivate "Display Properties"
But this approach is unreliable, because the user could click somewhere else so Enter would go to another window. Also, the Display Properties dialog caption is locale-dependent.
Another option would be to use the Theme.Manager
API provided by the themeui.dll library starting from Windows XP SP1, but it doesn't seem to work on XP SP2. Anyway, you can find sample code here.