Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Theme image file based on resolution


09 Sep 2010   #1

Windows 7 Enterprise
 
 
Theme image file based on resolution

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 System SpecsSystem Spec
.

09 Sep 2010   #2

Systems 1 and 2: Windows 7 Enterprise x64, Win 8 Developer
 
 

If your gpo is marked "no override", you will not be able to do it.
My System SpecsSystem Spec
09 Sep 2010   #3

Windows 7 Enterprise
 
 

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 System SpecsSystem Spec
.


13 Sep 2010   #4

Windows 7 Enterprise
 
 

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 System SpecsSystem Spec
13 Sep 2010   #5

Systems 1 and 2: Windows 7 Enterprise x64, Win 8 Developer
 
 

Thank you for letting us know. It may help someone in the future!
My System SpecsSystem Spec
14 Sep 2010   #6

Windows 7 Enterprise
 
 

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 System SpecsSystem Spec
01 Oct 2010   #7

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
02 Oct 2010   #8

Windows 7 Enterprise
 
 

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 Windows 7, 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 System SpecsSystem Spec
Reply

 Theme image file based on resolution




Thread Tools




Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 01:28 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33