自訂搜尋

2009/09/06

C# 用WMI控制開機重啟

ref system.management

using system.management;

ManagementClass mc_os = new ManagementClass("Win32_OperatingSystem");
mc_os.Scope.Options.EnablePrivileges = true;
foreach (ManagementObject mo in mc_os.GetInstances())
{
 mo.InvokeMethod("Shutdown", null, null);
}
mc_os.Dispose();

重啟 Reboot

沒有留言:

張貼留言

讀取中…