111,098
社区成员




ConnectionOptions options = new ConnectionOptions
{
Username = this.textBox1.Text,
Password = this.textBox2.Text
};
ManagementScope scope = new ManagementScope(@"\\" + this.textBox3.Text + @"\root\cimv2", options);
scope.Connect();
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
ManagementObjectCollection objects = new ManagementObjectSearcher(scope, query).Get();
foreach (ManagementObject obj2 in objects)
{
if (this.radioButton1.Checked)
{
obj2.InvokeMethod("reboot", null);
}
else
{
obj2.InvokeMethod("ShutDown", null);
}
}