Windows 7 标准用户的 WMI 权限
我有一个 .NET 应用程序,它使用 WMI 枚举串行端口并查找具有特定产品 ID 的设备。以管理员身份登录时,该应用程序运行良好,但我需要它以标准用户身份在 Windows 7 计算机上运行。
我尝试过以管理员身份运行它。不起作用。 我已将该用户添加到管理员组中。不起作用。 我已经更改了 WMI 控件的所有安全设置。不起作用。
任何帮助将不胜感激。
这是我的 WMI 代码。
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\WMI",
"SELECT * FROM MSSerial_PortName");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("MSSerial_PortName instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("PortName: {0} : Instance: {1} ", queryObj["PortName"], queryObj["InstanceName"]);
string instanceName = (string)queryObj["InstanceName"];
if (instanceName.Length > 0 && instanceName.Contains("6001"))
{
return (string)queryObj["PortName"];
}
}
I have an .NET application that uses WMI to enumerate serial ports and find a device with a specific product id. The application runs fine when logged in as an administrator, but I need it to run on a Windows 7 machine as a standard user.
I have tried running it as administrator. Doesn't work.
I have added the user to the administrator group. Doesn't work.
I have changed all the security settings from the WMI control. Doesn't work.
Any help would be greatly appreciated.
Here is my WMI code.
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\WMI",
"SELECT * FROM MSSerial_PortName");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("MSSerial_PortName instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("PortName: {0} : Instance: {1} ", queryObj["PortName"], queryObj["InstanceName"]);
string instanceName = (string)queryObj["InstanceName"];
if (instanceName.Length > 0 && instanceName.Contains("6001"))
{
return (string)queryObj["PortName"];
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论