The following codes will be helpfull for Shuting Down , Restarting or Logging Off Current System from a .Net Application.
Shuting Down C# - Remember to add Using System.Diagnostics Then in any Event Handler Enter
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
VB.Net - Remember to add Imports System.Diagnostics Then in any Event Handler Enter
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
Restarting Computer C# - Remember to add Using System.Diagnostics Then in any Event Handler Enter
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
VB.Net - Remember to add Imports System.Diagnostics Then in any Event Handler Enter
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
Logging Off C# - Remember to add Using System.Diagnostics Then in any Event Handler Enter
Process.Start("shutdown.exe","-l"); //This Code Will Directly Log Off the System Without warnings
VB.Net - Remember to add Imports System.Diagnostics Then in any Event Handler Enter
Process.Start("shutdown.exe","-l")'This Code Will Directly Log Off the System Without warnings
This Code Can Be Used in Both Console As Well As Windows Application
If you face any problems simply post a response. Regards Hefin Dsouza
|
No responses found. Be the first to respond and make money from revenue sharing program.
|