title: Batch or VBScript to check if Windows resolution is widescreen
body: <p>I'm trying to find/write a script (existing script is a batch file, although if VBS I could always call it within batch file) that can detect if the current screen resolution is a widescreen format, so that I can copy the appropriate background image to the machine. I've only found a couple posts with the same code, and as one reply said that you can always just set the image to be stretched. But that would mean that the image could be distorted (as others have said as well).</p>
  
  <p>I found the following VBScript from <a href="http://www.edugeek.net/forums/scripts/38928-vbs-detect-screen-resolution.html" rel="nofollow">this post</a>, although it only seems to work on Windows XP (although I haven't tried Windows 7 32-bit). In Windows 7 64 it just echos the asterick.</p>
  
  <pre><code>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
   Next 
  
  msgbox intHorizontal &amp; " * " &amp; intVertical 
  </code></pre>
  
  <p>But even if I could get this script to work, I would still have to have multiple IF's to match the Horizontal &amp; Vertical to a list of widescreen resolutions. Unless there's a math equation that I can use (which I'm sure there is). But regardless, I need a script that will work for both XP and 7 (32 &amp; 64), or if need be, two scripts for each OS or architecture.</p>
  
  <p>Thanks in advance,</p>
  
  <p>Brian</p>