|
|
|||||||
Hi, I need to dynamically change some computers' desktop wallpaper and background color on our network. I wondered if anyone had written anything yet in Kixtart that would do this and whether actually it is possible? Cheers kelp |
||||||||
|
|
|||||||
Yes, this is possible. The script below is a stripped version of what we have been running at the office for several years now. Please be aware that I did not test this stripped version but I see no reason for it not to work. Code: ;Region Set brake state. ;Set break state so terminating the script is possible without being logged off if the script is not running in logon mode. ;By default Break is set to off. If Not @LOGONMODE Break on EndIf ;endregion ;Region Get screen resolution. Select ;Get screen resolution for Windows Server 2008. Case InStr(@PRODUCTTYPE, "Windows Server 2008") ;Get the current screen resolution using WMI. $wmiColl = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_DisplayConfiguration") For Each $wmiObj in $wmiColl ;Combine width and height. $screenres = CStr($wmiObj.PelsWidth) + "x" + CStr($wmiObj.PelsHeight) Next Case 1 ;Get screen resolution for all non-Windows Server 2008 systems. $wmiColl = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_DesktopMonitor") For Each $wmiObj in $wmiColl ;Check if the found resolution is for the primary monitor. If $wmiObj.DeviceID = "DesktopMonitor1" ;Combine width and height. $screenres = CStr($wmiObj.ScreenWidth) + "x" + CStr($wmiObj.ScreenHeight) EndIf Next EndSelect ;Region Set wallpaper depending on location, user ID, or system ID. ;Set the wallpaper. $rc = SetWallpaper("C:\Wallpaper\Wallpaper" + $screenres + ".bmp", 1) ;Set the way the wallpaper is displayed. ;Stretched: WallpaperStyle = 2, TileWallpaper = 0. ;Centered: WallpaperStyle = 0, TileWallpaper = 0. ;Tiled: WallpaperStyle = 0, TileWallpaper = 1. $rc = WriteValue("HKU\" + @SID + "\Control Panel\Desktop", "TileWallpaper", "0", "REG_SZ") $rc = WriteValue("HKU\" + @SID + "\Control Panel\Desktop", "WallpaperStyle", "2", "REG_SZ") $rc = WriteValue("HKU\" + @SID + "\Software\Microsoft\Internet Explorer\Desktop\General", "TileWallpaper", "0", "REG_SZ") $rc = WriteValue("HKU\" + @SID + "\Software\Microsoft\Internet Explorer\Desktop\General", "WallpaperStyle", "2", "REG_SZ") ;Set background color to greenish blue. Use RGB values for the color. $rc = WriteValue("HKCU\Control Panel\Colors", "Background", "29 95 122", "REG_SZ") |
||||||||
|
|
|||||||
Thanks, that looks very interesting. Does it change the wallpaper / color instantly when run? I've found that when manually editing the registry to set, for instance, the background color, the color doesn't actually change until a logout or reboot. |
||||||||
|
|
|||||||
The wallpaper is set instantly but if I recall correctly the color only changes after a reboot so the new settings are applied. One way to "fix" this would be to close everything, launch task manager, kill explorer and use the "New task"-button in task manager to re-launch explorer. Not absoluitely sure if doing this applies the new color and I would not recommend that option. A restart would be the safest and cleanest way. |
||||||||
|
|
|||||||
Thanks for the answer. In the end, I hate to say it, but I've relented and used something other than Kixtart. I am able to deploy BGINFO via group policies and can also set up a scheduled task via GPO to run it on a regular basis too. BGINFO does change everything 'on the fly' when it's launched and I can then replace wallpaper when needed for the wallpaper to be changed whilst the user is still logged in. |
||||||||
|
|
|||||||
LOL BGINFO is part of what I took out in my example above. We use BGINFO in the logon script for servers. |
||||||||
|
|
|||||||
I ended up using a batch file to set mine. Mine also requires a reboot to set it Code: @ECHO OFF :: Paste the wallpaper, desired, due to its extension (type bmp or jpg), for an own folder within it. Do not modify the name of the desired file copy "C:\files\location.jpg" "C:\files\new\location.jpg" :: Add the required values ??to the registry, if these people are using a System Wallpaper. If they have always modified their wallpapers, the following lines are not necessary. "They have no habit of hurting themselves, constantly" REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "C:\files\new\location.jpg" :: Modify the following line in the last number to 0 if you want to center the bitmap on the desktop. Change the last number in the following line to 2 if you wish to extend the bitmap vertically and horizontally to fit on your desktop. REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D 2 :: Change to 0 (zero), the last number not to "pave" the image, set it to A (1) will be tiled. REG ADD "HKCU\Control Panel\Desktop" /V TileWallpaper /T REG_SZ /F /D 0 :: The following lines energize desktop %SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters ::The following line locks (locks) the workstation (server). ::%SystemRoot%\System32\RUNDLL32.EXE user32.dll, LockWorkStation |