1

打开硬件监视器没有向 WMI 提供任何实例

我正在运行最新版本的开放式硬件监视器 0.8.0 beta 和 Windows 10 pro 1903

使用 wmi explorer 我能够找到 root/OpenHardwareMonitor 路径,单击到 Sensors 但它找不到任何实例

import wmi
w = wmi.WMI(namespace="root\OpenHardwareMonitor")
temperature_infos = w.Sensor()
for sensor in temperature_infos:
    if sensor.SensorType == u'Temperature':
        print(sensor.Name)
        print(sensor.Value)

Python 给出以下错误:

Traceback (most recent call last):
  File "C:\Users\dean\PycharmProjects\gaming_stats\venv\lib\site-packages\wmi.py", line 817, in query
    return self._namespace.query (wql, self, fields)
  File "C:\Users\dean\PycharmProjects\gaming_stats\venv\lib\site-packages\wmi.py", line 1009, in query
    return [ _wmi_object (obj, instance_of, fields) for obj in self._raw_query(wql) ]
  File "C:\Users\dean\PycharmProjects\gaming_stats\venv\lib\site-packages\wmi.py", line 1009, in <listcomp>
    return [ _wmi_object (obj, instance_of, fields) for obj in self._raw_query(wql) ]
  File "C:\Users\dean\PycharmProjects\gaming_stats\venv\lib\site-packages\win32com\client\dynamic.py", line 252, in __getitem__
    return self._get_good_object_(self._enum_.__getitem__(index))
  File "C:\Users\dean\PycharmProjects\gaming_stats\venv\lib\site-packages\win32com\client\util.py", line 37, in __getitem__
    return self.__GetIndex(index)
  File "C:\Users\dean\PycharmProjects\gaming_stats\venv\lib\site-packages\win32com\client\util.py", line 53, in __GetIndex
    result = self._oleobj_.Next(1)
pywintypes.com_error: (-2147217372, 'OLE error 0x80041024', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/dean/PycharmProjects/gaming_stats/gaming_stats.py", line 3, in <module>
    temperature_infos = w.Sensor()
  File "C:\Users\dean\PycharmProjects\gaming_stats\venv\lib\site-packages\wmi.py", line 819, in query
    handle_com_error ()
  File "C:\Users\dean\PycharmProjects\gaming_stats\venv\lib\site-packages\wmi.py", line 241, in handle_com_error
    raise klass (com_error=err)
wmi.x_wmi: <x_wmi: Unexpected COM Error (-2147217372, 'OLE error 0x80041024', None, None)>

Process finished with exit code 1

这就是我从 PowerShell 中得到的

PS C:\WINDOWS\system32> get-wmiobject -namespace root\OpenHardwareMonitor -query 'select * from Sensor'
get-wmiobject : Provider is not capable of the attempted operation
At line:1 char:1
+ get-wmiobject -namespace root\OpenHardwareMonitor -query 'select * fr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], ManagementException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

来自 wmiexplorer:

09/08/2019 15:33:46 : Showing 0 cached instances for Sensor from 15:33:27
09/08/2019 15:33:46 : Showing 5 cached classes for ROOT\OpenHardwareMonitor from 15:33:26
09/08/2019 15:33:46 : Retrieved 5 classes from ROOT\OpenHardwareMonitor that match specified criteria.
09/08/2019 15:33:47 : Failed to enumerate instances from Sensor. ERROR: Provider is not capable of the attempted operation
4

0 回答 0