The Shutdown,LogOff and Restart processes can be handled through Process class
Use the namespace System.Diagonostics;
using System.Diagonostics;
Shut Down
In any event handler write this code:
Process.Start("shutdown.exe","-s");
// By Default the Shutdown will take place after 30 Seconds if you want to change the Delay use this one
Process.Start("shutdown.exe","-s -t xx"); //Replace xx with Seconds example 10,20 etc
Restart
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 xx");
//Replace xx with Seconds example 10,20 etc
Log Off
Process.Start("shutdown.exe","-l");
//This Code Will Directly Log Off the System Without warnings
No comments:
Post a Comment