Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set wallpaper with Group Policy 1

Status
Not open for further replies.

Timhi

Technical User
Apr 28, 2008
33
US
Hi. I'm Having some trouble with the wallpaper GPO. The Group Policy wants Active Desktop enabled in order to push a wallpaper to everyone in the domain. This in turn blocks them from changing it.

I want the ability to set a wallpaper, then allow anyone to change it. So unless there is a way to modify the registry, that is out of the question. Does anyone know if a script would be the easiest way to do this?

Thanks.
 
Here's I script I created.

Code:
'Set the wallpaper
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_VideoController",,48)
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("Process")
Set objFSO = CreateObject("Scripting.FileSystemObject")
sWinDir = objFSO.GetSpecialFolder(0)
  WinPath = sWinDir & "\NameWallpaper.bmp"
 
If Not objFSO.FileExists(winpath) then
'If the file does not exist then copy it
    For Each objItem in colItems
        sourcePath = "\\192.168.1.131\files\"
        rightSize = "Name" & objItem.CurrentHorizontalResolution & "x" & objItem.CurrentVerticalResolution & ".bmp"
        objFSO.CopyFile sourcePath & rightSize, sWinDir & "\NameWallpaper.bmp", overwrite = True
    Next
End If

'Set Wallpaper Bitmap to Default
sWallPaper = sWinDir & "\NameWallpaper.bmp"

' update in registry
WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", sWallPaper
WshShell.Regwrite "HKCU\Software\Microsoft\Internet Explorer\Desktop\General\Wallpaper", sWallPaper
WshShell.Regwrite "HKCU\Software\Microsoft\Internet Explorer\Desktop\General\BackupWallpaper", sWallPaper
' let the system know about the change
WshShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True
 
Thanks for the reply.. although that script is waaay above my head.

Here's what I ended up with:
Code:
copy \\pdc\screen\picture.bmp %SystemRoot%\picture.bmp 
REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "%SystemRoot%\picture.bmp"
REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D 2
REG ADD "HKCU\Control Panel\Desktop" /V TileWallpaper /T REG_SZ /F /D 0
%SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters

For some reason this only works on Enterprise Admin accounts. It copies the file and changes the registry perfectly. On all other accounts, it changes the registry as it should, but the picture.bmp will not copy from the server... The permissions on the "screen" share give full control to "Everyone". Since Enterprise admins can grab it I'm convinced it is a permissions issue.

Any idea what's going on?

Thanks.
 
Check your NTFS permissions on that share.

"We must fall back upon the old axiom that when all other contingencies fail, whatever remains, however improbable, must be the truth." - Sherlock Holmes

 
Thanks. I had forgotten that only local admins could create/modify contents of the Windows Directory. I moved the target location out of %systemroot% and it works great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top