//SHUT DOWN
protected void btnShutDown_Click(object sender, EventArgs e)
{
Process.Start("shutdown.exe", "-s"); // By Default the Shutdown will take place after 30 Seconds
//if you want to change the Delay try this one
Process.Start("shutdown.exe","-s -t xx"); //Replace xx with Seconds example 10,20 etc
}
//RESTART
protected void btnRestart_Click(object sender, EventArgs e)
{
Process.Start("shutdown.exe", "-r"); // By Default the Restart will take place after 30 Seconds
//if you want to change the Delay try this one
Process.Start("shutdown.exe","-r -t 10"); //Replace xx with Seconds example 10,20 etc
}
// LOG OFF
protected void btnLogOff_Click(object sender, EventArgs e)
{
Process.Start("shutdown.exe", "-l"); //This Code Will Directly Log Off the System Without warnings
}
C#实现系统关机、重启、注销等操作
最新推荐文章于 2024-02-01 00:16:29 发布
本文介绍了一个简单的C#程序,通过使用`shutdown.exe`命令,可以实现系统的重启、关机和注销操作。文章提供了详细的代码示例,并说明了如何调整延迟时间。
1万+

被折叠的 条评论
为什么被折叠?



