Monday 15 August 2011

Changing Background Colour and Wallpaper via Group Policy

Due to the powers that be I was tasked with ensuring no users had any wallpaper and that user's background were set to a specific colour. Easy peasy I thought a few group policy settings and away we go. Unfortunately there is no group policy for Background Colour, so I had to create a custom ADM file which contained the following:

CLASS USER

CATEGORY !!categoryname

KEYNAME "Control Panel\Colors"

POLICY !!policyname

EXPLAIN !!explaintext

PART !!labeltext DROPDOWNLIST REQUIRED

VALUENAME "Background"

ITEMLIST

NAME "Black" VALUE "0 0 0"

NAME "Blue" VALUE "58 110 165"

END ITEMLIST

END PART

END POLICY

END CATEGORY

[strings]

categoryname="Background Color Options"

policyname="Change the background color of the client computer"

explaintext="This policy sets the background color of the client computer"

labeltext="Choose a color"


Save the file in C:\Windows\inf\ as something like BackColour.adm

Using the Group Policy Management console either create and link a new GPO or edit an existing one. Right click Administrative Templates and select Add/Remove Templates, browse to your previous saved adm file and click Add. You should now see Background Color Options under Administrative Templates, however, it is likely the setting is not visible. Click on View, Filtering and untick Only show policy settings that can be fully managed, the setting should now be visible. Modiying the setting should now have the desired effect.

The background colour setting is not much use if a user has a desktop background set. There is already a setting in Group Policy under Desktop\Active Desktop\Active Desktop Wallpaper, which can be modified so the value is just a space ie No Wallpaper. On my Windows 7 machine this cleared my existing wallpaper but under Windows XP the previous wallpaper set by the user was still visible. After some investigating it transpires that this setting modifies the registry at HKCU\Software\Microsoft\Windows\Current Version\Policies\System\Wallpaper but another registry entry at HKCU\Control Panel\Desktop\Wallpaper was taking precedence. This is not the case for Vista\7 machines, presumably Microsoft changed this for situations like this.

To get around this I created another custom adm using the following text:

CLASS USER

CATEGORY !!categoryname

KEYNAME "Control Panel\Desktop"

POLICY !!policyname

EXPLAIN !!explaintext

PART "Path: " EDITTEXT REQUIRED

VALUENAME "Wallpaper"

END PART

END POLICY

END CATEGORY

[strings]

categoryname="Default Background"

policyname="Change the background image of the client computer"

explaintext="This policy sets the background image of the client computer"

labeltext="Choose an image"

Add this into the Group Policy Object using the method described earlier. You can now enter a space for the Path value and this will remove the entry in HKCU\Control Panel\Desktop\Wallpaper which for Windows XP users equates to no background! A little longer than expected but finally the desired effect.