I'm trying to access my CPU temperature using a WMI query because people said you can do it. I'm using a script I got online, and when I try to output the queried data it just gives me not supported thread. Here is the error output:
System.Management.ManagementObjectCollectionA first chance exception of type 'System.Management.ManagementException' occurred in System.Management.dll
The thread 0xc8ac has exited with code 259 (0x103).
A first chance exception of type 'System.Management.ManagementException' occurred in System.Management.dll
An error occurred while querying for WMI data: Not supported System.Management.ManagementObjectCollectionAn error occurred while querying for WMI data: Not supported The thread 0x9928 has exited with code 259 (0x103).
A first chance exception of type 'System.Management.ManagementException' occurred in System.Management.dll
System.Management.ManagementObjectCollectionAn error occurred while querying for WMI data: Not supported The program '[49728] GetHardwareInfo.vshost.exe: Program Trace' has exited with code 0 (0x0).
The program '[49728] GetHardwareInfo.vshost.exe' has exited with code 0 (0x0).
I'm going to assume it's because there is no data, but I'm not sure.
private void get_cpu_temp()
{
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"root\WMI", "SELECT * FROM MSAcpi_ThermalZoneTemperature");
Console.Write(searcher.Get());
foreach (ManagementObject queryObj in searcher.Get())
{
double temp = double.Parse(queryObj["CurrentTemperature"].ToString());
temp = (temp - 2732) / 10d;
Console.Write(temp.ToString());
}
}
catch (ManagementException err)
{
Console.Write("An error occurred while querying for WMI data: " + err.Message);
}
}