Link to home
Start Free TrialLog in
Avatar of ddotson
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\SYSTEM\CurrentControlSet\Hardware Profiles\0001\System\CurrentControlSet\Control\VIDEO\{19E5EBEB-9F36-42E3-86C1-E032FB21EA07}\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?
Avatar of Shane Russell
Shane Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

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)
  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_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:

with createobject("internetexplorer.application")
    .navigate "about:blank"
    with .document.parentWindow.screen
      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
I appolgise for my last post !!

I found this :

Set WSHShell = WScript.CreateObject("WScript.Shell")
set objSysInfo = Wscript.CreateObject("SYSINFO.Sysinfo")

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 ?
Avatar of ddotson
ddotson

ASKER

Thanks for the correction.  I also found that script.  Here's the error I get:

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.
ASKER CERTIFIED SOLUTION
Avatar of Shane Russell
Shane Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ddotson

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.