Simplest way to Programmatically ShutDown or Restart your System using C#
Feb 10, 2010
Question is...
One of the ways to ShutDown or Restart your system is to use WMI (Windows Management Interface). However it does require you to write a few lines of code.
I have found that the simplest way to ShutDown or Restart your computer is to use the Process class in the System.Diagnostics namespace. Here’s an example:
Simplest way to Programmatically ShutDown or Restart your System using C#
One of the ways to ShutDown or Restart your system is to use WMI (Windows Management Interface). However it does require you to write a few lines of code.
I have found that the simplest way to ShutDown or Restart your computer is to use the Process class in the System.Diagnostics namespace. Here’s an example:
private void btnShutDown_Click(object sender, EventArgs e)
{
Process.Start("shutdown", "-s -f -t 0");
}
private void btnRestart_Click(object sender, EventArgs e)
{
Process.Start("shutdown", "-r -f -t 0");
}
Share