【发布时间】:2014-12-24 12:08:20
【问题描述】:
我正在尝试使用 WMI 组件访问远程机器的服务状态(如果有任何替代建议)。
以下是我的代码:
public void MonitorService()
{
ConnectionOptions con = new ConnectionOptions();
con.Username = "username";
con.Password = "password";
con.Authority = "ntlmdomain:somedomain";
con.Authentication = AuthenticationLevel.Connect;
con.EnablePrivileges = true;
con.Impersonation = ImpersonationLevel.Identify;
ManagementScope scope = new ManagementScope(@"\\machinename\root\cimv2", con);
scope.Connect();
ManagementPath path = new ManagementPath("Win32_Service");
ManagementClass services;
services = new ManagementClass(scope, path, null);
foreach (ManagementObject service in services.GetInstances())
{
// some manipulations
}
}
在scope.Connect(),我收到错误“HRESULT 异常:0x80070005 (E_ACCESSDENIED)”
我在ConnectionOption 中使用的用户在远程系统上拥有管理员权限。
我已允许用户访问远程机器中的 WMI COM 对象。我已经通过link 但没有帮助我。请告诉我我缺少的东西。
【问题讨论】: