1

I am trying to get specific property values stored in WMI on a remote computer. The properties I am looking for are not in one of the normal namespaces such as Win32_ComputerSystem nor Win32_DesktopMonitor. It's stored inside root\wmi WmiMonitorBasicDisplayParams.

The specific properties I need are MaxHorizontalImageSize and MaxVerticalImageSize for each connected monitor on the remote computer.

The closest i can get with the WMI module is:

monitor_data = wmi.WMI(moniker="//./root/wmi:WmiMonitorBasicDisplayParams")

This gives me the type "<class 'wmi.wmi_class'> and looks like this:

{
        [key, read] string InstanceName;
        [read] boolean Active;
        [WmiDataId(1), read] uint8 VideoInputType;
        [WmiDataId(2), read] uint8 MaxHorizontalImageSize;
        [WmiDataId(3), read] uint8 MaxVerticalImageSize;
        [WmiDataId(4), read, WmiScale(-2)] uint8 DisplayTransferCharacteristic;
        [WmiDataId(5), read] WmiMonitorSupportedDisplayFeatures SupportedDisplayFeatures;
};

If I try to access the MaxHorizontalImageSize property, i get the type "<class 'wmi.wmi_property'> and printing it directly gives "<wmi_property: MaxHorizontalImageSize>"

print(monitor_data.MaxHorizontalImageSize)

This property should have 2 numbers in it from the 2 connected displays but i cant figure out how to actually access the values.

The above solution also only works on the local machine, i need to get it from remote machines. Typically with WMI, i can get remote info by doing this:

pc = wmi.WMI('ComputerName')
data_i_want = pc.Win32_Processor()

But I don't know how this would be done when using a moniker like above. I know I could create and call a powershell script and read the return value, but i would prefer to keep everything within Python and not have to call powershell. I imagine this can be access via the WMI module, i just dont know what's missing.

Mattias
  • 11
  • 1

0 Answers0