Theme image file based on resolution

xarden

New member
Guru
Local time
10:39 PM
Messages
905
Location
Auckland
Hi there,

I've got a .theme file on a network share thats being pushed out by gpo.

In the .theme file itself, this part:
Code:
[Control Panel\Desktop]
Wallpaper=%SystemDrive%\IT\Themes\Wallpapers\1024x768-no-text.jpg
TileWallpaper=0
WallpaperStyle=2
Pattern=
specifies to use 1024x768-no-text.jpg

What I would like to do is specify a different file, (eg: 800x600-no-text.jpg, 1920x1080-no-text.jpg) based on the resolution of the monitor itself.
So a 1920x1080 reso screen will get the 1920x1080 image, similar to the way the login screen works by using 1024x768background.jpg

Reason being, a 4:3 image contorts our Logo when stretched on a 16:9 monitor.

Is there a way to do this?
 

My Computer

OS
Windows 7 Enterprise
CPU
Intel Pentium Dual E2200 @2.2GHz
Motherboard
Gigabyte II-G31
Memory
4GB
Graphics Card(s)
Palit GForce 9500GT 1GB
Sound Card
onBoard
Hard Drives
WesternDigital: 250GB + 1TB + 1TB + 2TB
PSU
450W
Case
CoolerMaster CM690
Cooling
Corsair H50
Mouse
Logitech MX518
If your gpo is marked "no override", you will not be able to do it.
 

My Computer

Computer Manufacturer/Model Number
Dell and Custom
OS
Systems 1 and 2: Windows 7 Enterprise x64, Win 8 Developer
CPU
System 1: i7 [email protected], System 2: AMD FX-4100 Zambezi 3.6G
Motherboard
System 1:Dell 06NWYK System 2: ASUS M5A97 AM3+
Memory
System 1: 8GB System 2: 8GB
Graphics Card(s)
System 1: ATI FirePro V4800 System 2: Radeon HD 6850
Sound Card
System 1: onboard System 2: onboard
Monitor(s) Displays
System1: Viewsonic HDMI 24"
Screen Resolution
System 1: 1920x1080 System 2: 1920x1080
Hard Drives
System 1: Mirrored .5B drives System 2: Seagate Barracuda ST1000DM003 1TB 7200 RPM 64MB Cache SATA 6.0Gb/s
Case
System 1: Dell System 2: Cooler Master
Internet Speed
10 MBPS
Its not.
The theme loads fine and works. It shouldnt matter whether the .theme is applied by GP, or locally.

Its the selecting of the image inside the .theme file that I need to set conditionally.

Im currently looking at VBS options, so instead of specifying a .jpg, specify a .vbs file.
The vbs script should 'hopefully' could return a path to the .jpg file.
Unless this is taking me in the wrong direction, and theres another way?
 

My Computer

OS
Windows 7 Enterprise
CPU
Intel Pentium Dual E2200 @2.2GHz
Motherboard
Gigabyte II-G31
Memory
4GB
Graphics Card(s)
Palit GForce 9500GT 1GB
Sound Card
onBoard
Hard Drives
WesternDigital: 250GB + 1TB + 1TB + 2TB
PSU
450W
Case
CoolerMaster CM690
Cooling
Corsair H50
Mouse
Logitech MX518
Maybe Solved:
I've set the .theme to use the 1024x768-no-text.jpg as stated in the code section of my first post. This is generally the default screen res, as most of our monitors are this size.
Additionally, I've written up a vbs script to be included in the User login script.

Code:
set fso = CreateObject("Scripting.FileSystemObject")
set objWMIService = GetObject("Winmgmts:\\.\root\cimv2")
set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor Where DeviceID = 'DesktopMonitor1'",,0)
	for Each objItem in colItems
		intH = objItem.ScreenHeight
		intW = objItem.ScreenWidth
	Next

'Uncomment to echo the screen resolution
'WScript.echo intW&"x"intH

  Path ="C:\IT\Themes\Wallpapers\"
  file = intW&"x"&intH&"-no-text.jpg"
  F = Path&file
	
if (fso.FileExists(F)) then
	set objShell = createObject("Shell.application")
	set objFolder = objShell.Namespace(Path)
	set objItem = objFolder.ParseName(file)
	for Each objVerb in objItem.Verbs
		if objVerb.name = "Set as desktop &background" then
			objVerb.DoIt
			objItem.invokeVerb("setdesktopwallpaper")
		end if
	Next
end if

That seems to do the trick.
It will find the screen res, then troll through the 'Path' folder to find the 'file'.
If its found, it will then troll through the file Verbs (Context menu) to find the set as desktop background.
If thats found, it will apply it.
If the file isnt found, then the script finishes and remains with the default 1024x768 image.

In theory, the objVerb.DoIt and objItem.InvokeVerb() both do the same thing. However, when used individually, neither work. So I've just called upon them both.

So, by setting the GPO to force the theme instead of a specific image, users are still able to change the background picture to whatever they like. It just wont remember it next time they log in.
 

My Computer

OS
Windows 7 Enterprise
CPU
Intel Pentium Dual E2200 @2.2GHz
Motherboard
Gigabyte II-G31
Memory
4GB
Graphics Card(s)
Palit GForce 9500GT 1GB
Sound Card
onBoard
Hard Drives
WesternDigital: 250GB + 1TB + 1TB + 2TB
PSU
450W
Case
CoolerMaster CM690
Cooling
Corsair H50
Mouse
Logitech MX518
Thank you for letting us know. It may help someone in the future!
 

My Computer

Computer Manufacturer/Model Number
Dell and Custom
OS
Systems 1 and 2: Windows 7 Enterprise x64, Win 8 Developer
CPU
System 1: i7 [email protected], System 2: AMD FX-4100 Zambezi 3.6G
Motherboard
System 1:Dell 06NWYK System 2: ASUS M5A97 AM3+
Memory
System 1: 8GB System 2: 8GB
Graphics Card(s)
System 1: ATI FirePro V4800 System 2: Radeon HD 6850
Sound Card
System 1: onboard System 2: onboard
Monitor(s) Displays
System1: Viewsonic HDMI 24"
Screen Resolution
System 1: 1920x1080 System 2: 1920x1080
Hard Drives
System 1: Mirrored .5B drives System 2: Seagate Barracuda ST1000DM003 1TB 7200 RPM 64MB Cache SATA 6.0Gb/s
Case
System 1: Dell System 2: Cooler Master
Internet Speed
10 MBPS
Update for those that are following...
Added an OS check, so the background change script will only work on Windows versions 6 or higher, to exclude XP based machines.
Note the 'commented out' lines. These were giving intermittant issues.
Uncomment the wscript.echo lines for debugging if you want to.

Code:
strComputer = "."
Set objWMI = GetObject("winmgmts:\\"& strComputer & "\root\CIMV2")
Set colItemss = objWMI.ExecQuery("SELECT * FROM Win32_OperatingSystem",,48)
For Each objItemm in colItemss
'	Wscript.Echo objItemm.Caption
'	Wscript.Echo objItemm.Version
	Verr = objItemm.Version
'	WScript.Echo "ServicePack " & objItemm.ServicePackMajorVersion
Next

if Verr >= "6" then
'wscript.echo "Verson 6 or higher. ("&Verr&")"

		set fso = CreateObject("Scripting.FileSystemObject")
		set objWMIService = GetObject("Winmgmts:\\.\root\cimv2")
		set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor Where DeviceID = 'DesktopMonitor1'",,0)
			for Each objItem in colItems
				intH = objItem.ScreenHeight
				intW = objItem.ScreenWidth
			Next

		  Path ="C:\IT\Themes\Wallpapers\"
		  file = intW&"x"&intH&"-no-text.jpg"
		  F = Path&file
			
		if (fso.FileExists(F)) then
			set objShell = createObject("Shell.application")
			set objFolder = objShell.Namespace(Path)
			set objItem = objFolder.ParseName(file)
			for Each objVerb in objItem.Verbs
'commented out	'	if objVerb.name = "Set as desktop &background" then
'commented out	'		objVerb.DoIt
					objItem.invokeVerb("setdesktopwallpaper")
'commented out	'	end if
			Next
		end if

else
'wscript.echo "Lesser OS"
end if

All done :)
 

My Computer

OS
Windows 7 Enterprise
CPU
Intel Pentium Dual E2200 @2.2GHz
Motherboard
Gigabyte II-G31
Memory
4GB
Graphics Card(s)
Palit GForce 9500GT 1GB
Sound Card
onBoard
Hard Drives
WesternDigital: 250GB + 1TB + 1TB + 2TB
PSU
450W
Case
CoolerMaster CM690
Cooling
Corsair H50
Mouse
Logitech MX518
or you could just have a single wallpaper that is big enough for your higest res display and apply that to all the screens

Windows will automatically scale it to fit the screen
 

My Computer

Computer Manufacturer/Model Number
Gateway DX4831
OS
Windows 7 Ultimate x64
CPU
Intel i3 :(
Motherboard
OEM Intel H57
Memory
6GB DDR3 1333
Graphics Card(s)
NVIDIA GeForce GT 220 :(
Sound Card
Built IN
Monitor(s) Displays
Gateway HX2000 @ 1600x900 :(
Screen Resolution
1600x900
Hard Drives
1TB Western Digital
Internet Speed
Comcast 20MB down 5 MB up
You're not wrong, we could.
But we have a range of monitors, ranging from 24" @ 16:9, and 17" @ 4:3
Our logo then gets stretched out of shape and looks horrid.
For this reason, the Marketing department have made up 12 new pictures at each resolution we use.

On other developments outside Win7, our Novell guy has made a script as part of the deployment process, that will download all the drivers required from a net share, based on the chipset of the PC the image is being deployed to.
We're now also exploring the option of having a similar script for the background image. So it will replace the background picture with the one that matches the maximum resolution the sceen can handle. This is also based on the chipset of the attached monitor(s). This is well before windows starts up for the first time, so windows wouldnt know any better.
 

My Computer

OS
Windows 7 Enterprise
CPU
Intel Pentium Dual E2200 @2.2GHz
Motherboard
Gigabyte II-G31
Memory
4GB
Graphics Card(s)
Palit GForce 9500GT 1GB
Sound Card
onBoard
Hard Drives
WesternDigital: 250GB + 1TB + 1TB + 2TB
PSU
450W
Case
CoolerMaster CM690
Cooling
Corsair H50
Mouse
Logitech MX518
Back
Top