batch file以CPU为单位获取CPU温度并设置为variables

我如何获得一个batch file来计算出CPU的温度并将其作为一个variables返回。 我知道这可以做,因为我已经看到它已经完成。 该解决scheme可以使用任何外部工具。 我在Google上看了至less2个小时,但什么都没发现。 任何人都可以帮忙 谢谢。

这是一个保留十进制值并使用完整转换值的示例。

@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 

产量

 38.05 Degrees Celsius 

您可以使用wmic.exe :

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

wmic的输出如下所示:

 CurrentTemperature 2815 

MSAcpi_ThermalZoneTemperature的单位是开尔文的十分之一,所以如果你想要摄氏度,你可以这样做:

 @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% 

一些东西:

1)该属性可能会或可能不会被您的硬件支持。

2)该值可能会或可能不会在每个引导周期更新超过一次。

3)您可能需要管理权限来查询该值。

如果你电脑支持它,你可以尝试这样的:

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

这将输出开氏度的温度。