2008年8月27日星期三

C#,利用Shutdown.exe重启计算机



public static class Shutdown
{
public static Shutdown()
{
//Restart pc ("-r") after 120 sencond. ("-s"=shutdown pc)
Process.Start(ShutdownPath, string.Format(" -r -t {0}", 120));
}

public static CancelShutdown()
{
Process.Start(ShutdownPath, " -a");
}

private static string ShutdownPath
{
get
{
return Path.Combine(Environment.GetFolderPath
(Environment.SpecialFolder.System),
"shutdown.exe");
}
}
}

没有评论: