目标机器的防火墙已关闭。远程访问权限全开了。
代码如下:
ConnectionOptions co = new ConnectionOptions();
co.Username = "administrator";
co.Password = "";
System.Management.ManagementScope ms = new ManagementScope("\\\\192.168.1.30\\root\\cimv2", co);
ms.Connect();
System.Management.ObjectQuery oq = new ObjectQuery("SELECT*FROM Win32_OperatingSystem");
ManagementObjectSearcher query1 = new ManagementObjectSearcher(ms,oq);
ManagementObjectCollection queryCollection1 = query1.Get();
foreach (ManagementObject mo in queryCollection1)
{
string[] ss = { "" };
mo.InvokeMethod("Reboot", ss);
Console.WriteLine(mo.ToString());
报错地方是ms.connect();提示说要有足够的资源权限。如何解决。