user5447339
user5447339

Reputation:

How can we get a CPU temperature through WMI?

I installed WMI code creator from here, and I'm wondering how we can use it to get the CPU temperature.

The application gives many options (as shown below), but I am not sure where I have to click to get the CPU temperature.

enter image description here

I went to the description of WMI code creator and saw the following:

The WMI Code Creator tool allows you to generate VBScript, C#, and VB .NET code that uses WMI to complete a management task such as querying for management data, executing a method from a WMI class, or receiving event notifications using WMI.

Upvotes: 11

Views: 50853

Answers (4)

Carsten
Carsten

Reputation: 2201

On my Dell-Laptop I could get the CPU-Temperature in Celsius like this:

$data = Get-WMIObject -Query "SELECT * FROM Win32_PerfFormattedData_Counters_ThermalZoneInformation" -Namespace "root/CIMV2"
@($data)[0].HighPrecisionTemperature

Upvotes: 3

Bacon Bits
Bacon Bits

Reputation: 32180

For those looking for a PowerShell solution:

Get-CimInstance -Namespace root/wmi -ClassName MsAcpi_ThermalZoneTemperature -Filter "Active='True' and CurrentTemperature<>2732" -Property InstanceName, CurrentTemperature |
    Select-Object InstanceName, @{n='CurrentTemperatureC';e={'{0:n0} C' -f (($_.CurrentTemperature - 2732) / 10.0)}}

The WMI/CIM filter here is only looking for active sensors that aren't returning 0 C as the temperature. My system returns several sensors with that value and I assume they're just disabled or otherwise non-functional. The InstanceName property should give you an approximate idea where the sensor is located. In my systems, even though the property is supposed to be in tenths of degrees K, it's always reporting in whole degree values and it appears to round the -273.15 C absolute zero to -273.2. Other systems or sensors may vary.

Note that you must be an administrator to query the MsAcpi_ThermalZoneTemperature class.

Upvotes: 4

Mochamad Aris Zamroni
Mochamad Aris Zamroni

Reputation: 51

My HP laptop has HP specific WMI objects that contains temperature in Celcius units and fan RPM speed objects. Running this WMIC command in administrator mode will retrieve them:

wmic /NAMESPACE:\\root\HP\InstrumentedBIOS path HPBIOS_BIOSNumericSensor get Name,CurrentReading

Adding for syntax for looping it every 5 seconds:

FOR /L %G IN (1,1,100) DO wmic /NAMESPACE:\\root\HP\InstrumentedBIOS path HPBIOS_BIOSNumericSensor get Name,CurrentReading && PING localhost -l 0 -n 5 >NUL

Upvotes: 2

Sebastian Hildebrandt
Sebastian Hildebrandt

Reputation: 2781

Namespace: root\wmi
Path: MSAcpi_ThermalZoneTemperature

To run this (using wmic) from the Windows command line (cmd.exe) the command would be:

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

Attention: the results are in Kelvin * 10, so you need to divide the result by 10, and then subtract 273.15 to get °Celsius.


More information:

Upvotes: 20

Related Questions