“拒绝访问”使用WMI获取温度 [英] "access denied" while getting temperature using WMI
本文介绍了“拒绝访问”使用WMI获取温度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码试图使用WMI来获取计算机温度。
它在searcher.Get()过程中因访问被拒绝异常而失败。
我试图使用计算机管理设置WMI服务的安全性。
但这似乎不会影响异常。
我也设置了清单中的管理员权限 - 没有帮助。
代码在两台不同的Windows 8.1计算机上失败但在Windows 7计算机上成功。
任何想法?
--- Jim
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
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);
}
推荐答案
我似乎使用以下信息解决了这个问题:
http://bytes.com/topic/visual-basic-net/answers/382910-cpu-temperature [ ^ ]
这个页面描述了一个名为wbemtest.exe的实用程序,它是windows的一部分。
这个实用程序可以让你测试本地机器的WMI功能。
只需在命令提示符下键入它。
执行连接以进入本地机器。
然后单击查询并输入您尝试与WMI一起使用的WMI命令
例如:从acpi_temperaturezone中选择*
在我的情况下,响应显示这不可用。
还有:select * from win32_temperatureprobe
返回结果---但在我的情况下,当前读数显示为null。
再次显示我正在使用的笔记本电脑中的主板。 br $> b $ b
--- Jim
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
这篇关于“拒绝访问”使用WMI获取温度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文