Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch-file get CPU temperature in °C and set as variable

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.

like image 366
09stephenb Avatar asked Jun 02 '14 22:06

09stephenb


People also ask

Can you check CPU temp with CMD?

Way 3: View CPU temperature via tools provided by manufacturers. Press the Windows key + R to open Run dialog box. Type "CMD" and press "Enter" to open Command Prompt. Type wmic baseboard get product, manufacturer and press "Enter".

How can I check my CPU temp without any software?

If you're running Windows 11, Windows 10, or an earlier version, it includes its own temperature check built into the BIOS/UEFI. To access it, turn on your PC and press a specific key during startup — usually F12, ESC, F2, or DEL. Once BIOS/UEFI is open, it shows you the CPU temperature right on the main screen.

What is a normal temperature for CPU?

low processor usage (in standard operation): approximately 30 to 50 °C (86 to 122 °F) intense usage through programs that require high processing performance: up to 95 °C (up to 203 °F) the maximum temperature, whenever possible, should not exceed 100 °C (212 °F)

IS 30 C hot for a CPU?

25–30 degrees Celsius is not high for a PC to running at. I would say it is within the normal idle range, which can vary depending on the ambient temperature in the room itself, which affects the efficiency of the cooling system.


3 Answers

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.

like image 51
Kevin Richardson Avatar answered Oct 27 '22 08:10

Kevin Richardson


Here is an example which keeps the decimal values and uses the full conversion value.

Code

@echo off
for /f "skip=1 tokens=2 delims==" %%A in ('wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature /value') do set /a "HunDegCel=(%%~A*10)-27315"
echo %HunDegCel:~0,-2%.%HunDegCel:~-2% Degrees Celsius

Output

38.05 Degrees Celsius
like image 42
David Ruhmann Avatar answered Oct 27 '22 10:10

David Ruhmann


If you computer support it you can try like this :

 wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature

This will output the temperature in degree Kelvin.

like image 20
SachaDee Avatar answered Oct 27 '22 08:10

SachaDee