Theme image file based on resolution


  1. Posts : 966
    Windows 7 Enterprise
       #1

    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 Computer


  2. Posts : 3,139
    Systems 1 and 2: Windows 7 Enterprise x64, Win 8 Developer
       #2

    If your gpo is marked "no override", you will not be able to do it.
      My Computer


  3. Posts : 966
    Windows 7 Enterprise
    Thread Starter
       #3

    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


  4. Posts : 966
    Windows 7 Enterprise
    Thread Starter
       #4

    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


  5. Posts : 3,139
    Systems 1 and 2: Windows 7 Enterprise x64, Win 8 Developer
       #5

    Thank you for letting us know. It may help someone in the future!
      My Computer


  6. Posts : 966
    Windows 7 Enterprise
    Thread Starter
       #6

    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


  7. Posts : 93
    Windows 7 Ultimate x64
       #7

    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


  8. Posts : 966
    Windows 7 Enterprise
    Thread Starter
       #8

    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


 

  Related Discussions
Our Sites
Site Links
About 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 05:53.
Find Us