How do i get a batch-file to work out the temperature of the Cpu and return it as a variable. I know it can be done as i have seen it been done. The solution can use any external tool. I have looked on Google for at least 2 hours but found nothing. Can any one help. Thanks.
You can use wmic.exe:
wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature
The output from wmic
looks like this:
CurrentTemperature
2815
The units for MSAcpi_ThermalZoneTemperature
are tenths of degrees Kelvin, so if you want celsius, you'd do something like this:
@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%
A few things:
1) The property may or may not be supported by your hardware.
2) The value may or may not update more than once per boot cycle.
3) You may need Administrative privileges to query the value.