您的位置:首页 > 编程语言 > C#

C#实现系统关机、重启、注销等操作

2015-05-28 17:25 671 查看
//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
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: