private void RebootComputer()
{
try
{
ManagementObject classInstance = new ManagementObject("root\\CIMV2", "Win32_OperatingSystem.", null);
// Execute the method and obtain the return values.
ManagementBaseObject outParams = classInstance.InvokeMethod("Reboot", null, null);
// List outParams
Console.WriteLine("Out parameters:");
Console.WriteLine("ReturnValue: " + outParams["ReturnValue"]);
}
catch (ManagementException err)
{
MessageBox.Show("WMI执行错误: " + err.Message);
}
我是想用wmi实现,如果只要重启,我都可以用exitwindows()实现
我想搞清楚ManagementObject classInstance = new ManagementObject("root\\CIMV2", "Win32_OperatingSystem.", null);这个格式错在什么地方
|