Page 1 of 1 1
Topic Options
#212196 - 2017-01-09 10:44 AM Desktop wallpaper / background color
kelp7 Offline
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 Moderator Offline
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.

 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")
_________________________
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 Offline
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
#212209 - 2017-01-11 10:32 AM Re: Desktop wallpaper / background color [Re: kelp7]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
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.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#212212 - 2017-01-11 05:06 PM Re: Desktop wallpaper / background color [Re: Mart]
kelp7 Offline
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
#212213 - 2017-01-12 10:23 AM Re: Desktop wallpaper / background color [Re: kelp7]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
LOL BGINFO is part of what I took out in my example above. We use BGINFO in the logon script for servers.

Edited by Mart (2017-01-12 10:23 AM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#212382 - 2017-03-27 07:57 AM Re: Desktop wallpaper / background color [Re: Mart]
Schavuit Offline
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

 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

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.054 seconds in which 0.024 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org