Scripts Thread, VBS detect Screen Resolution in Coding and Web Development; Any ideas on how to achieve this?
Google isn't helping much, and I've not tracked down a single script that ...
17th July 2009, 04:15 PM #1
VBS detect Screen Resolution
Any ideas on how to achieve this?
Google isn't helping much, and I've not tracked down a single script that works. Is it even possible?
What we want to do is host the background for student desktops locally on each machine to save on network traffic, so I want to write a VBS script to copy down the correct version from the server the first time the workstation is started up after imaging, but to copy down a different version depending on screen resolution as we have a nice wallpaper designed by one of my techs that works well with BG info, but it needs to be displayed at the correct resolution to work.
Can anyone help!
Thanks in anticipation,
IDG Tech News
17th July 2009, 04:25 PM #2
Within BGInfo you have the option to stretch an image, so it'll cover any resolution. Double click BGInfo.exe, navigate to: Background, specify the wallpaper, then specify the Wallpaper Position as 'Stretch' from the drop down menu.
17th July 2009, 04:45 PM #3
Set objWMIService = GetObject("Winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor where DeviceID = 'DesktopMonitor1'",,0)
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
msgbox intHorizontal & " * " & intVertical
2 Thanks to mac_shinobi:
Ignatius (17th July 2009), maniac (17th July 2009)
17th July 2009, 05:19 PM #4
Yes, but that kind of messes things up when someone's made the effort to be creative and make something that will look wrong when it's stretched :-)
Originally Posted by Michael
17th July 2009, 05:33 PM #5
Thanks for that mac_shinobi
Just out of interest where did you find it or did you just happen to know the code? I've searched for ages and the only codes I found were for ASP web pages, or used really complex methods to grab the data.
And yes srochford you're right, stretching it is not an option for this background - we've got pre-defined boxes on one side of it which BG info will populate with info for us (Specifically logged on username and logon time) and these need to be the same size and in exactly the same place on each background for BGinfo to put the text in the correct place. Also stretching it just distorts it all and makes text look naff, and I want our system to be top notch in all respects.
17th July 2009, 05:34 PM #6
17th July 2009, 05:37 PM #7
I was looking at that very site earlier, guess it depends exactly what you type in the search box as to what comes up - Nonsense in, Nonsense out.
Originally Posted by kmount
17th July 2009, 05:39 PM #8
It's called WMI - and I found it there and a few other places.
There is another way by using internet explorer to do it for you but did not have much time to do it that way so just posted the wmi way which is a lot neater and better solution
see below ( from one of my EE posts ) obviously this is more for setting the resolution then getting ( aside from the script below using internet explorer )
This is what I have found :
How do I change screen resolution or wallpaper?
Screen resolution cannot be changed from WSH. Here are some workarounds, almost entirely taken from Torgeir Bakken's responses on this topic.
Use Multires (which is free) <-- as mentioned below you can use the multires exe to apply screen resolutions etc
Here's a reference to doing it via Java
It should also be possible to do this using the ChangeDisplaySettings API, but you would need to write a component to access it.
Win9x clients running the QuickRes powertoy can run a shell command like this:
RunDLL deskcp16.dll,QUICKRES_RUNDLLENTRY 1280x1024x24
FINDING the screen resolution is possible, albeit not "natively" - here's a quick script that will give you current screen resolution via Internet Explorer:
Wallpaper can be modified in the registry; unfortunately, changes don't take place until you refresh, either by logoff/logon or by manually refreshing the desktop.
msgbox .width & " by " & .height
The relevant registry key is HKCU\Control Panel\Desktop\Wallpaper. To see an example script of copying wallpaper and changing it, see:
There is a rundll32 command to update the HKCU section of the registry as well which will update it without logging off and back on
I got that from this site :
Last edited by mac_shinobi; 17th July 2009 at 06:00 PM.
17th July 2009, 05:57 PM #9
if you just want to set it and forget it i use a script on the pcs ou that on bootup copy's a batch file to c:\documents and settings\all users\start menu\programs\startup
use qures.exe (i copy to c:\windows so its pathed) then batch file in all user\startup is
just change the numbers as appropriate (i use 16 as some sherston software cant hack 32 bit colour)
qres /x:1440 /y:900 /c:16
17th July 2009, 05:59 PM #10
you can do that with multi res as well and for multiple monitors
Originally Posted by sted
17th July 2009, 06:42 PM #11
Grrr! I've also been searching for this to incorporate into BGInfo for a while. Thanks mac_shinobi for the solution.
17th July 2009, 08:58 PM #12
If the question is "how do I use a script to find out XXX about my PC" then the answer is almost always "use WMI" :-)
Given that little acronym, googling just becomes so much easier!
A really good way to find out what you can do with WMI is to use the Microsoft Scriptomatic tool
17th July 2009, 09:23 PM #13
I wish someone (else, my comments go in one ear and out the other) would tell that to one of the IT staff here. He hasn't updated his video driver. I know I'm a pedant, but I just can't stand seeing things displayed in 4:3 on a widescreen monitor. The entire thing is stretched horizontally.
Originally Posted by srochford
20th July 2009, 10:25 AM #14
One thing that annoys me as well that it, TFT screens being set to anything except their native resolution always looks rubbish.
Originally Posted by kearton
By tmcd35 in forum How do you do....it?
Last Post: 4th March 2009, 12:38 PM
By rh91uk in forum Windows Vista
Last Post: 12th November 2008, 06:20 PM
By theeldergeek in forum Windows
Last Post: 14th May 2008, 12:39 PM
By plock in forum Windows
Last Post: 17th December 2007, 02:56 PM
By Geoff in forum Thin Client and Virtual Machines
Last Post: 19th July 2006, 11:24 AM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)