我有这段代码:
private ManagementScope CreateNewManagementScope(string server)
{
string serverString = "\\\\" + server + "\\root\\cimv2";
ConnectionOptions options = new ConnectionOptions();
options.Username = "name";
options.Password = "password";
ManagementScope scope = new ManagementScope(serverString, options);
scope.Connect();
return scope;
}
使用该代码,我试图通过 WMI 远程访问另一台 PC。密码和用户名 100% 正确(我用 wmic /node:pc /username:name /password:pwd 对其进行了测试,这有效)但我被拒绝访问
(来自 HRESULT 的异常:0x80070005 (E_ACCESSDENIED))
任何想法我做错了什么?我正在使用 Win 7/C#/.NET 4.0 感谢您的帮助!