Some of the WMI Queries don't work with the VBScript Field() function RRS feed

  • General discussion

  • I was directed here from

    I can define and display fields as

    • SELECT Caption FROM Win32_DiskDrive
    • SELECT DeviceID FROM Win32_DiskDrive
    • SELECT Index FROM Win32_DiskDrive
    • SELECT Size FROM Win32_DiskDrive
    • SELECT Status FROM Win32_DiskDrive

    but when I try to retrieve them in VBScript using the Field() function, then the first three work just fine, but I receive just an empty string from the last two. Is there a type conversion issue?

    I find the same issue with

    • SELECT MonitorType FROM Win32_DesktopMonitor

    but not with

    • SELECT MonitorName FROM Win32_DesktopMonitor

    though, which are both strings...

    Digging a bit more, I find that

    • SELECT ScreenHeight FROM Win32_DesktopMonitor

    is fine, but

    • SELECT ScreenWidth FROM Win32_DesktopMonitor

    is not. This is nuts!

    This is on Windows 10 Pro 64-bit 10.0.18363 (1909) using BGInfo 4.28.

    Tuesday, September 29, 2020 6:25 PM

All replies

  • I don't think it's a bginfo problem. On my Win10 Home 2004 laptop, both ScreenHeight and ScreenWidth are null. But other fields like PixelsPerXLogicalInch have values.  I tested that using Powershell.

    get-ciminstance -query "SELECT * FROM Win32_DesktopMonitor" | format-list -Property *

    Another tool that I use to view WMI values is ScriptoMatic. It generates VB script code. 


    Powershell output:

    PS C:\WINDOWS\system32> get-ciminstance -query "SELECT * FROM Win32_DesktopMonitor" | format-list -Property *
    DeviceID                    : DesktopMonitor1
    Name                        : Generic PnP Monitor
    PixelsPerXLogicalInch       : 96
    PixelsPerYLogicalInch       : 96
    ScreenHeight                :
    ScreenWidth                 :
    IsLocked                    :
    LastErrorCode               :
    Status                      : OK
    StatusInfo                  :
    Caption                     : Generic PnP Monitor
    Description                 : Generic PnP Monitor
    InstallDate                 :
    Availability                : 8
    ConfigManagerErrorCode      : 0
    ConfigManagerUserConfig     : False
    CreationClassName           : Win32_DesktopMonitor
    ErrorCleared                :
    ErrorDescription            :
    PNPDeviceID                 : DISPLAY\LGD0464\4&12A86449&0&UID265988
    PowerManagementCapabilities :
    PowerManagementSupported    :
    SystemCreationClassName     : Win32_ComputerSystem
    SystemName                  : SLICK
    Bandwidth                   :
    DisplayType                 :
    MonitorManufacturer         : (Standard monitor types)
    MonitorType                 : Generic PnP Monitor
    PSComputerName              :
    CimClass                    : root/cimv2:Win32_DesktopMonitor
    CimInstanceProperties       : {Caption, Description, InstallDate, Name...}
    CimSystemProperties         : Microsoft.Management.Infrastructure.CimSystemProperties

    Tuesday, September 29, 2020 10:46 PM
  • I too am a big fan of scriptomatic..

    so generally I do this..

    a cmd that run a first vbscript that output the data to a text file, then start bginfo with a config that load data from the text file.. that way there is no problem doing anything..

    Something like this:

    bginfo c:\temp\config.bgi /timer:0


    Wednesday, September 30, 2020 8:30 AM