+ Post New Thread
Results 1 to 10 of 10
Windows 7 Thread, WMI Help - Win32_DesktopMonitor for Terminal Session in Technical; Hi, I was wondering if there is a equivalent WMI to Win32_DesktopMonitor for an RDP session to determine the resolution ...
  1. #1

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,955
    Thank Post
    886
    Thanked 1,700 Times in 1,477 Posts
    Blog Entries
    12
    Rep Power
    448

    WMI Help - Win32_DesktopMonitor for Terminal Session

    Hi,

    I was wondering if there is a equivalent WMI to Win32_DesktopMonitor for an RDP session to determine the resolution of the session please?

    I have a little logon script that will look at the screen resolution of a computer and apply the correct wallpaper. When using it on RDP it uses the host resolution. It uses Win32_DesktopMonitor so if there is something that will work for the session that would help.

    @Arthur is good with WMI so he maybe able to help

    Thanks

  2. #2


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,899
    Thank Post
    226
    Thanked 2,676 Times in 1,973 Posts
    Rep Power
    787
    If you run the following VBScript in your RDP session, does it return the correct resolution?

    Code:
    On Error Resume Next
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_DisplayConfiguration",,48)
    For Each objItem in colItems
        Wscript.Echo objItem.PelsWidth & " x " & objItem.PelsHeight
    Next

  3. #3

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,955
    Thank Post
    886
    Thanked 1,700 Times in 1,477 Posts
    Blog Entries
    12
    Rep Power
    448
    No. It shows the resolution as 1024 x 768. The host is 1280 x 1024 and the session is 1108 x 663.

    Thanks

  4. #4


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,899
    Thank Post
    226
    Thanked 2,676 Times in 1,973 Posts
    Rep Power
    787
    What about this VBScript?

    Code:
    ScreenRes = funcScreenResolution() 
     
    Function funcScreenResolution() 
        Set objIE = CreateObject("InternetExplorer.Application") 
        objIE.Navigate("about:blank") 
        Do Until objIE.readyState = 4: Loop 
            width = objIE.document.ParentWindow.screen.width 
            height = objIE.document.ParentWindow.screen.height 
        objIE.Quit 
        funcScreenResolution = array(width,height) 
    End Function 
     
    wscript.Echo ScreenRes(0) & " x " & ScreenRes(1)
    How are you connecting to the session e.g. via an RDP file?

  5. Thanks to Arthur from:

    FN-GM (13th March 2012)

  6. #5

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,955
    Thank Post
    886
    Thanked 1,700 Times in 1,477 Posts
    Blog Entries
    12
    Rep Power
    448
    Quote Originally Posted by Arthur View Post
    How are you connecting to the session e.g. via an RDP file?
    Via HP ThinClients. But i run the first script via a RDP session using sonicwall SSL VPN.

    The second script works

    This is a sample of the script we use. How would i go about adapting it please?

    Thanks

    Code:
    Set objWMIService = GetObject("Winmgmts:\\.\root\cimv2") 
    Set objSh = CreateObject("Wscript.Shell")
    Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor where DeviceID = 'DesktopMonitor1'",,0) 
    For Each objItem in colItems 
        intHorizontal = objItem.ScreenWidth 
        intVertical = objItem.ScreenHeight 
    Next
    
    strResolution = CStr(intHorizontal) & " x " & CStr(intVertical)
    
    Select Case strResolution
    Case "1024 x 768"
            strWallpaperPath = "C:\Program Files\Wallpaper\Staff\1024x768.jpg"
    Case "1280 x 800"
            strWallpaperPath = "C:\Program Files\Wallpaper\Staff\1280x800.jpg"
    Case "1280 x 1024"
            strWallpaperPath = "C:\Program Files\Wallpaper\Staff\1280x1024.jpg"
    Case Else
    End Select
    
    'Set the reg value
    objSh.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", strWallpaperPath, "REG_SZ"
    
    'Apply the change
    objSh.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 0, False

  7. #6


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,899
    Thank Post
    226
    Thanked 2,676 Times in 1,973 Posts
    Rep Power
    787
    Since 1108x663 is a bit of a strange resolution, do you think it would be better to choose the wallpaper based on the aspect ratio of the display or session instead of the resolution?

  8. #7

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,955
    Thank Post
    886
    Thanked 1,700 Times in 1,477 Posts
    Blog Entries
    12
    Rep Power
    448
    Its because i am using a Windows VM on my Mac to connect. Its just the window size i dragged the VM to and then connected full screen. In production its just the usual resolutions

    To be honest i would rather go for a wallpaper that matches the resolution if we can.

    Thanks

  9. #8

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,955
    Thank Post
    886
    Thanked 1,700 Times in 1,477 Posts
    Blog Entries
    12
    Rep Power
    448
    Would the script be something like the below?

    Thanks

    Code:
    ScreenRes = funcScreenResolution() 
     
    Function funcScreenResolution() 
        Set objIE = CreateObject("InternetExplorer.Application") 
        objIE.Navigate("about:blank") 
        Do Until objIE.readyState = 4: Loop 
            width = objIE.document.ParentWindow.screen.width 
            height = objIE.document.ParentWindow.screen.height 
        objIE.Quit 
        funcScreenResolution = array(width,height) 
    End Function 
     
    strResolution = ScreenRes(0) & " x " & ScreenRes(1)
    
    Select Case strResolution
    Case "1024 x 768"
            strWallpaperPath = "C:\Program Files\Wallpaper\Staff\1024x768.jpg"
    Case "1280 x 800"
            strWallpaperPath = "C:\Program Files\Wallpaper\Staff\1280x800.jpg"
    Case "1280 x 1024"
            strWallpaperPath = "C:\Program Files\Wallpaper\Staff\1280x1024.jpg"
    Case Else
    End Select
    
    'Set the reg value
    objSh.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", strWallpaperPath, "REG_SZ"
    
    'Apply the change
    objSh.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 0, False

  10. #9


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,899
    Thank Post
    226
    Thanked 2,676 Times in 1,973 Posts
    Rep Power
    787
    I made a few changes to your script and tested it in a Windows 7 VM, but can't get the wallpaper to change. Something to do with RunDLL32 perhaps?

    I'll have another look tomorrow later today when my brain is working properly.
    Last edited by Arthur; 13th March 2012 at 01:10 AM.

  11. Thanks to Arthur from:

    FN-GM (15th March 2012)

  12. #10

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,955
    Thank Post
    886
    Thanked 1,700 Times in 1,477 Posts
    Blog Entries
    12
    Rep Power
    448
    This seems to work. I shall feedback and let you know how i get on.

    Thanks

    Code:
    Set objSh = CreateObject("Wscript.Shell")
    
    ScreenRes = funcScreenResolution() 
    Function funcScreenResolution() 
        Set objIE = CreateObject("InternetExplorer.Application") 
        objIE.Navigate("about:blank") 
        Do Until objIE.readyState = 4: Loop 
            width = objIE.document.ParentWindow.screen.width 
            height = objIE.document.ParentWindow.screen.height 
        objIE.Quit 
        funcScreenResolution = array(width,height) 
    End Function 
     
    strResolution = ScreenRes(0) & " x " & ScreenRes(1)
    
    Select Case strResolution
    Case "1024 x 768"
            strWallpaperPath = "C:\Program Files\Wallpaper\Staff\1024x768.jpg"
    Case "1280 x 800"
            strWallpaperPath = "C:\Program Files\Wallpaper\Staff\1280x800.jpg"
    Case "1280 x 1024"
            strWallpaperPath = "C:\Program Files\Wallpaper\Staff\1280x1024.jpg"
    Case Else
    End Select
    
    'Set the reg value
    objSh.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", strWallpaperPath, "REG_SZ"
    
    'Apply the change
    objSh.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 0, False

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 7
    Last Post: 1st August 2007, 09:47 PM
  2. Replies: 6
    Last Post: 15th June 2007, 12:30 PM
  3. help required for school charity fundraiseing Event(
    By rama1712 in forum General Chat
    Replies: 9
    Last Post: 20th April 2007, 10:22 PM
  4. Login Freezes For Terminal Services
    By Pear in forum Windows
    Replies: 5
    Last Post: 24th January 2007, 05:31 PM
  5. Helpful information for you all.
    By Dos_Box in forum Windows
    Replies: 9
    Last Post: 27th September 2005, 08:01 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •