ddotson
asked on
Get Screen Resolution for use in VBS Login Script
I am running a login script (XP) that changes the default wallpaper to the user's custom wallpaper. After getting it ready to deploy, I discovered that the use of high-res bitmaps on lower-res monitors looks terrible. So, I have created a lower-res wallpaper for this purpose. Now I need to write my login script to check the screen resolution and then set the wallpaper accordingly.
I searched the web and EE for this solution, but wasn't too successful. I found a key that appears to store the screen resolution, but when I try to read it with .regread, it fails. Here is the code that is failing:
wshShell.RegRead ("HKEY_LOCAL_MACHINE\SYSTE M\CurrentC ontrolSet\ Hardware Profiles\0001\System\Curre ntControlS et\Control \VIDEO\{19 E5EBEB-9F3 6-42E3-86C 1-E032FB21 EA07}\0000 "))
So, the question is: where in the registry is the screen resolution stored, and what is the best way to retrieve it using a VBS file?
I searched the web and EE for this solution, but wasn't too successful. I found a key that appears to store the screen resolution, but when I try to read it with .regread, it fails. Here is the code that is failing:
wshShell.RegRead ("HKEY_LOCAL_MACHINE\SYSTE
So, the question is: where in the registry is the screen resolution stored, and what is the best way to retrieve it using a VBS file?
I appolgise for my last post !!
I found this :
Set WSHShell = WScript.CreateObject("WScr ipt.Shell" )
set objSysInfo = Wscript.CreateObject("SYSI NFO.Sysinf o")
wscript.echo objSysInfo.WorkAreaHeight
wscript.echo objSysInfo.WorkAreaWidth
Only thing is, is that I think it returns it in twips and not pixels so I am currently trying to figure out how to convert it into pixels :)
Unless that is ok for you ?
I found this :
Set WSHShell = WScript.CreateObject("WScr
set objSysInfo = Wscript.CreateObject("SYSI
wscript.echo objSysInfo.WorkAreaHeight
wscript.echo objSysInfo.WorkAreaWidth
Only thing is, is that I think it returns it in twips and not pixels so I am currently trying to figure out how to convert it into pixels :)
Unless that is ok for you ?
ASKER
Thanks for the correction. I also found that script. Here's the error I get:
Could not locate automation class "Sysinfo.sysinfo"
Could not locate automation class "Sysinfo.sysinfo"
Here is the site I got it from :
http://groups.msn.com/windowsscript/wshgeneralquestions.msnw?action=view_list&row=28&viewtype=2&sortstring=
On there it says it uses sysinfo.ocx
So maybe you need to download sysinfo.ocx and register it and try to use that vbscript again.
You can download it from here :
http://www.dynamiclink.nl/htmfiles/rframes/info_ocx/info_s/44.htm
However your best option would be to download the vb 6 runtime files because it is included in there.
http://www.microsoft.com/downloads/details.aspx?familyid=7b9ba261-7a9c-43e7-9117-f673077ffb3c&displaylang=en
I hope this helps some what.
http://groups.msn.com/windowsscript/wshgeneralquestions.msnw?action=view_list&row=28&viewtype=2&sortstring=
On there it says it uses sysinfo.ocx
So maybe you need to download sysinfo.ocx and register it and try to use that vbscript again.
You can download it from here :
http://www.dynamiclink.nl/htmfiles/rframes/info_ocx/info_s/44.htm
However your best option would be to download the vb 6 runtime files because it is included in there.
http://www.microsoft.com/downloads/details.aspx?familyid=7b9ba261-7a9c-43e7-9117-f673077ffb3c&displaylang=en
I hope this helps some what.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This worked great. I was worried that it wasn't a very elegant solution, but it ran very quick, and got the information I needed! Thanks!
Your welcome ! I was glad I could help you out and thanks for the grade and points.
==========================
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)
http://www.entechtaiwan.com/multires.htm
Here's a reference to doing it via Java
http://home.istar.ca/~neutron/JDirect/DisplaySettings/
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_RUND
FINDING the screen resolution is possible, albeit not "natively" - here's a quick script that will give you current screen resolution via Internet Explorer:
with createobject("internetexpl
.navigate "about:blank"
with .document.parentWindow.scr
msgbox .width & " by " & .height
end with
end with
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.
The relevant registry key is HKCU\Control Panel\Desktop\Wallpaper. To see an example script of copying wallpaper and changing it, see:
http://groups.google.com/groups?selm=uFMs1Zq1AHA.2092%40tkmsftngp05
==========================
I got that from this site :
http://www.mvps.org/scripting/faq/wshfaq.htm
I hope this helps some what :)
If I find anything else of use I will post back