Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The following code is an attempt to use WMI to get the computer temperature.
It fails with an "access denied" exception upon the searcher.Get() procedure.
I have attempted to set the security for the WMI service using the Computer Management.
But this doesn't seem to affect the exception.
I have also set the Administrator privileges in the manifest -- no help.
The code fails on two different Windows 8.1 machines but is successful on a Windows 7 machine.
Any ideas?
--- Jim
C#
List<double> result = new List<double>();
ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"root\WMI", "SELECT * FROM MSAcpi_ThermalZoneTemperature");
foreach (ManagementObject obj in searcher.Get())
{
     Double temp = Convert.ToDouble(obj["CurrentTemperature"].ToString());
     temp = (temp - 2732) / 10.0;
     result.Add(temp);
}
Posted
Comments
Sergey Alexandrovich Kryukov 1-Sep-14 16:07pm    
Windows 8 sucks? :-)
—SA
[no name] 1-Sep-14 16:19pm    
Check to make sure that the motherboard actually has a temperature sensor.
Member 10020245 4-Sep-14 8:22am    
wouldn't all mobos or CPU have a temp sensor??

My real problem is that the USB rate on the tabletPC seems to drop as a temp is reached. With Tablet outside in the sunlight, I can measure the temp with LED thermometer and see a temp at top-right of the Tablet at about 120 degF (Dell Venue Pro). At this temp, my USB connection to my digital camera fails. I want to monitor the CPU temp to determine when this occurrence is imminent. Maybe I need to revert to Windows 7 ..
Jim
[no name] 5-Sep-14 14:01pm    
No not all do that's the point.

1 solution

I seemingly resolved this using the information at:
http://bytes.com/topic/visual-basic-net/answers/382910-cpu-temperature[^]

this page described the use of a utility called "wbemtest.exe" that is a part of windows.
This utility lets you test the WMI capability of the local machine.

Just type it at the Command Prompt.
Do a "Connect" to get to the local machine.

Then click "query" and type in the WMI command you are attempting to use with WMI
e.g. : Select * from acpi_temperaturezone

In my case, the response showed this was not available.
There is also: select * from win32_temperatureprobe
This returns results --- but the "current reading" is shown as "null" in my case.
Again showing that the mobo in the laptop I am using.

--- Jim
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900