[C#] C#控制Windows系统关系、重启和注销 →→→→→进入此内容的聊天室

来自 , 2020-07-20, 写在 C#, 查看 174 次.
URL http://www.code666.cn/view/db9e6eef
  1. //SHUT DOWN
  2.         protected void btnShutDown_Click(object sender, EventArgs e)
  3.         {            
  4.             Process.Start("shutdown.exe", "-s"); // By Default the Shutdown will take place after 30 Seconds
  5.  
  6.             //if you want to change the Delay try this one
  7.             Process.Start("shutdown.exe","-s -t xx"); //Replace xx with Seconds example 10,20 etc
  8.         }
  9.  
  10. //RESTART
  11.         protected void btnRestart_Click(object sender, EventArgs e)
  12.         {
  13.             Process.Start("shutdown.exe", "-r"); // By Default the Restart will take place after 30 Seconds
  14.  
  15.             //if you want to change the Delay try this one
  16.             Process.Start("shutdown.exe","-r -t 10"); //Replace xx with Seconds example 10,20 etc
  17.         }
  18.  
  19. // LOG OFF
  20.         protected void btnLogOff_Click(object sender, EventArgs e)
  21.         {
  22.             Process.Start("shutdown.exe", "-l"); //This Code Will Directly Log Off the System Without warnings
  23.         }
  24. //csharp/7536

回复 "C#控制Windows系统关系、重启和注销"

这儿你可以回复上面这条便签

captcha