在公司的局域网连接是可以的。
但是远程却不行。不知道是什么原因?
rpc服务是开着的。 请各位大侠帮忙?
ConnectionOptions options =
new ConnectionOptions();
options.Username = "Administrator";
options.Password = "zxcvbnm";
//options.Authority = "ntdlmdomain:default";
ManagementScope scope =
new ManagementScope(
"\\\\59.56.175.35\\root\\cimv2", options);
try
{
scope.Connect();
ObjectQuery query = new ObjectQuery(
"SELECT * FROM Win32_OperatingSystem");
ManagementObjectSearcher searcher =
new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
// Display the remote computer information
Console.WriteLine("Computer Name : {0}",
m["csname"]);
Console.WriteLine("Windows Directory : {0}",
m["WindowsDirectory"]);
Console.WriteLine("Operating System: {0}",
m["Caption"]);
Console.WriteLine("Version: {0}", m["Version"]);
Console.WriteLine("Manufacturer : {0}",
m["Manufacturer"]);
}
}
catch (Exception me)
{
Console.WriteLine("异常:" + me.Message);
}