我正在使用以下代码使用WMI连接到远程计算机:
ConnectionOptions connOptions = new ConnectionOptions();
connOptions.Impersonation = ImpersonationLevel.Impersonate;
connOptions.EnablePrivileges = true;
connOptions.Username = "admin";
connOptions.Password = "password";
ManagementScope scope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", remoteMachine), connOptions);
scope.Connect();
Run Code Online (Sandbox Code Playgroud)
我收到以下异常:RPC服务器不可用.(HRESULT异常:0x800706BA)
检查了本知识库文章中描述的所有步骤,远程计算机上的一切正常.
用户是远程计算机上的管理员.
尝试过Wbemtest工具,结果相同
有谁知道发生了什么?
谢谢你,
Vasyl
如果您在Win7下,则必须以管理员身份运行应用程序.您还可以为connOptions.Impersonation属性尝试不同的值.你在远程机器上打开RPC端口了吗?尝试在两台计算机上关闭防火墙altogeter.