#212196 - 2017-01-09 10:44 AM
Desktop wallpaper / background color
|
kelp7
Starting to like KiXtart
Registered: 2002-08-12
Posts: 124
Loc: UK
|
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
|
Top
|
|
|
|
#212204 - 2017-01-10 09:21 AM
Re: Desktop wallpaper / background color
[Re: kelp7]
|
Mart
KiX Supporter
Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
|
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.
;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")
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.
|
Top
|
|
|
|
#212207 - 2017-01-10 04:19 PM
Re: Desktop wallpaper / background color
[Re: Mart]
|
kelp7
Starting to like KiXtart
Registered: 2002-08-12
Posts: 124
Loc: UK
|
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.
|
Top
|
|
|
|
#212212 - 2017-01-11 05:06 PM
Re: Desktop wallpaper / background color
[Re: Mart]
|
kelp7
Starting to like KiXtart
Registered: 2002-08-12
Posts: 124
Loc: UK
|
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.
|
Top
|
|
|
|
#212382 - 2017-03-27 07:57 AM
Re: Desktop wallpaper / background color
[Re: Mart]
|
Schavuit
Fresh Scripter
Registered: 2016-09-30
Posts: 14
Loc: South Korea
|
I ended up using a batch file to set mine. Mine also requires a reboot to set it
@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
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 507 anonymous users online.
|
|
|