0
I’m creating a program for Windows
and need to get the user’s CPU temperature. For this task I am using the wmic
with the following code in batch
:
@echo off
for /f "delims== tokens=2" %%a in (
'wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature /value'
) do (
set /a degrees_celsius=%%a / 10 - 273
)
echo %degrees_celsius% GRAUS
pause
The problem is that the temperature shown is always 64 GRAUS
and the original return of wmic
is the temperature in Kelvin of 3372
. I did several tests to confirm whether this temperature was correct or not. I turned off the computer and waited a while for the CPU to cool, opened temperature measurement programs, and the result of that program in batch
was always the same.
I’m doing something wrong, it’s some problem in the wmic
or the lack of any resource on my computer ?
Just strengthening, here also the value is not changing, Windows 10. I put the CPU for stress test and the value does not change.
– Leonardo Getulio
Why not pull directly from the Windows API by writing some application? I have a temperature reading application via API and works well in all versions above Windows 7.
– Leonardo Getulio
The program I am creating is in Python. I searched the Windows API documentation for "pywin32" but there is nothing there related to temperature. Before anyone speaks, libraries that have temperature measurement functions for Python do not work on my computer (I tested all libraries I found on the internet).
– JeanExtreme002