Maximum Error Posted October 4, 2013 Share Posted October 4, 2013 So we're trying to role out a company wide desktop background. The only problem is we have a few different resolutions running on the network. I've narrowed it down to having two files - a widescreen one and a normal one but I cant see a way to deploy this. Deploying it per usergroup wont work as we have different resolutions there too. Any of you guys come across this before? I'm assuming there must be a script somewhere but i wouldn't know how to check the current resolution etc. Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/ Share on other sites More sharing options...
Arachno 1D Posted October 4, 2013 Share Posted October 4, 2013 Cant you make a generic one with a "fit to screen" option or will it distort the image? Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-595995843 Share on other sites More sharing options...
Maximum Error Posted October 4, 2013 Author Share Posted October 4, 2013 Yeah i tried that but it distorts :( They want an image that really has to be at least aspect ratio compliment. Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-595995855 Share on other sites More sharing options...
Maximum Error Posted October 4, 2013 Author Share Posted October 4, 2013 You can either create one OU in AD for each device resolution and apply a different GPO for each or use a script to detect the screen resolution and apply the correct wallpaper at logon Have you any idea of where i can find some documentation on what would need to be included in that script? I would prefer that option as it would be automatic for new machines and not require a new OU. Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-595995857 Share on other sites More sharing options...
McKay Posted October 4, 2013 Share Posted October 4, 2013 Couldn't you do one wallpaper with the resolution 2560x1440 to cover the largest 16:9 resolution, and a 2560x1600 resolution to cover the largest 16:10 resolution. Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-595995865 Share on other sites More sharing options...
Maximum Error Posted October 4, 2013 Author Share Posted October 4, 2013 Detect resolution strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_DisplayConfiguration") For Each objItem in colItems Wscript.Echo "Name: " & objItem.DeviceName Wscript.Echo "Color depth: " & objItem.BitsPerPel Wscript.Echo "Horizontal resolution: " & objItem.PelsWidth Wscript.Echo "Vertical resolution: " & objItem.PelsHeight Wscript.Echo Next Change wallpaper using VBScript Dim WshShell Set WshShell = WScript.CreateObject("Wscript.Shell") WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", mybitmap.bmp WshShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters", 1, False Set WshShell = Nothing Sorry I cant quote or paste hyperlinks on this forum as I use IE11. Just google run vbscript via GPO on user logon Excellent thanks! I'll give this a go :) Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-595996655 Share on other sites More sharing options...
Maximum Error Posted October 4, 2013 Author Share Posted October 4, 2013 Detect resolution strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_DisplayConfiguration") For Each objItem in colItems Wscript.Echo "Name: " & objItem.DeviceName Wscript.Echo "Color depth: " & objItem.BitsPerPel Wscript.Echo "Horizontal resolution: " & objItem.PelsWidth Wscript.Echo "Vertical resolution: " & objItem.PelsHeight Wscript.Echo Next Change wallpaper using VBScript Dim WshShell Set WshShell = WScript.CreateObject("Wscript.Shell") WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", mybitmap.bmp WshShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters", 1, False Set WshShell = Nothing Sorry I cant quote or paste hyperlinks on this forum as I use IE11. Just google run vbscript via GPO on user logon Presumably there needs to be some sort of condition in there? Like if resolution 1280x1024 then use wallpaper1280x1024.jpg? Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-595996673 Share on other sites More sharing options...
Maximum Error Posted October 7, 2013 Author Share Posted October 7, 2013 Yes indeed. let me get out of work (about 2 hours) and I will write you the script Thank you :) That would be amazing. Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-596002501 Share on other sites More sharing options...
cgratton Posted October 15, 2013 Share Posted October 15, 2013 Resident Fanatic Did you ever get around to re-writing this script with the if statement? Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-596024885 Share on other sites More sharing options...
cgratton Posted October 15, 2013 Share Posted October 15, 2013 Riva do you have an update? Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-596024889 Share on other sites More sharing options...
cgratton Posted October 15, 2013 Share Posted October 15, 2013 you assistance with this would be greatly appericated, as i'm facing the same issue. Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-596025053 Share on other sites More sharing options...
cgratton Posted October 16, 2013 Share Posted October 16, 2013 what would i add if i have 4 different resolutions? 1024x768 800x600 1280x800 1680x1050 would it look like this If objItem.ScreenWidth > 1024 Then WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\1024.jpg"If objItem.ScreenWidth > 800 Then WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\800.jpg"If objItem.ScreenWidth > 1280 Then WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\1280.jpg" If objItem.ScreenWidth > 1680 Then WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\1680.jpg" Else WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\normal.jpg" End If will this work? Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-596026379 Share on other sites More sharing options...
cgratton Posted October 16, 2013 Share Posted October 16, 2013 Riva, in that post i just posted, would i use this instead of a desktop GPO meaning would i just put the script and images in a folder then great a logon script inside the GPO?? ideally i would like to run the script once let it determine the image to put out then ignore it moving forward. The real issue that i'm facing is we have 4 images at dif resolutions, i can push out via GPO but the images look streached or messed up...i'm hoping running this script will help me in this situation. Could you chim in to the steps i need to take? Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-596026417 Share on other sites More sharing options...
HawkMan Posted October 16, 2013 Share Posted October 16, 2013 what would i add if i have 4 different resolutions? 1024x768 800x600 1280x800 1680x1050 would it look like this If objItem.ScreenWidth > 1024 Then WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\1024.jpg"If objItem.ScreenWidth > 800 Then WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\800.jpg"If objItem.ScreenWidth > 1280 Then WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\1280.jpg" If objItem.ScreenWidth > 1680 Then WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\1680.jpg" Else WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\normal.jpg" End If will this work? Been a while since I did programming like this and I didn't do much VB(any) but I don't think you can do if/else like that, then you have to nest them. So for multiple resolution you would instead use another function with multiple cases, or you could use nested if's. Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-596026469 Share on other sites More sharing options...
Maximum Error Posted October 16, 2013 Author Share Posted October 16, 2013 On Error Resume Next Dim WshShell Set WshShell = WScript.CreateObject("Wscript.Shell") strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_DesktopMonitor",,48) For Each objItem in colItems If objItem.ScreenWidth > 1024 Then WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\wide.jpg" Else WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\normal.jpg" End If WshShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters", 1, False Next Set WshShell = Nothing Thank you so much! :) Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-596026479 Share on other sites More sharing options...
cgratton Posted October 16, 2013 Share Posted October 16, 2013 +Maximum Error did this work for you? Were you trying to roll out desktop background to all users in your environment? did this work with dif resolutions? How did you complete? Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-596026781 Share on other sites More sharing options...
AStaUK Posted October 17, 2013 Share Posted October 17, 2013 Interesting script, I'd be interesting in knowing how well this works for you +Maximum Error. I tried rolling out a static wallpaper to all my users a while ago through GPO and locked down the Display applet so it couldn't be modified only to find that you could still from within IE set a different wallpaper and override the one specified within the GPO. Annoyingly so did my users, not that it was a big deal. Shortly after we abandoned the idea of using a static wallpaper and allowed the to choose their own. Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-596028809 Share on other sites More sharing options...
cgratton Posted October 17, 2013 Share Posted October 17, 2013 So is this what the entire script looks like? strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_DisplayConfiguration") For Each objItem in colItems Wscript.Echo "Name: " & objItem.DeviceName Wscript.Echo "Color depth: " & objItem.BitsPerPel Wscript.Echo "Horizontal resolution: " & objItem.PelsWidth Wscript.Echo "Vertical resolution: " & objItem.PelsHeight Wscript.Echo Next If objItem.ScreenWidth = 1024 Then WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\1024.jpg" ElseIf objItem.ScreenWidth = 800 Then WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\800.jpg" ElseIf objItem.ScreenWidth = 1280 Then WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\1280.jpg" ElseIf objItem.ScreenWidth = 1680 Then WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\1680.jpg" Else WshShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", "C:\normal.jpg" End If ?? Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-596029371 Share on other sites More sharing options...
cgratton Posted October 17, 2013 Share Posted October 17, 2013 When running the script i get and error? --------------------------- Windows Script Host --------------------------- Script: C:\Users\cgratton\Desktop\blue.vbs Line: 15 Char: 1 Error: Object required: 'objItem' Code: 800A01A8 Source: Microsoft VBScript runtime error --------------------------- OK --------------------------- Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-596029431 Share on other sites More sharing options...
Louisifer Posted October 17, 2013 Share Posted October 17, 2013 I've done very little with VB over the years but I can see that the conditions aren't in the loop and therefore objitem doesn't exist :P In short move "Next" to the bottom. Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-596029473 Share on other sites More sharing options...
cgratton Posted October 17, 2013 Share Posted October 17, 2013 could you show my what you mean? Link to comment https://www.neowin.net/forum/topic/1180377-gpo-to-push-different-wallpaper-files-dependant-on-resolution/#findComment-596029489 Share on other sites More sharing options...
Recommended Posts