How To Shut Down Your Computer In C#



Shutdown computer in C#




using System.Diagnostics;
///////////////////////////////////////////
String shutdown;

/////////// Start Button //////////////////
Process.Start("Shutdown", shutdown + " -t " + textBox1.Text + @" -c ""Windows is going to shut down!""");
// -t = time , -c = comments
timer1.Start();
label3.Text = textBox1.Text;

/////////// Abort Button //////////////////
Process.Start("Shutdown", "-a"); timer1.Stop(); // -a = abort

/// ComboBox_SelectedIndexChanged Event ///
switch (comboBox1.SelectedIndex)
{
case 0: shutdown = "-s"; break; // -s = shutdown
case 1: shutdown = "-r"; break; // -r = restart
case 2: shutdown = "-l"; break; // -l = log off
}

/////////// Timer_Tick Event //////////////
label3.Text = (Convert.ToInt32(label3.Text) - 1).ToString();



-----------------------------------------
.net - How to shutdown the computer from C#
Shut Down, Restart, Log off or Lock your computer in C#
How To Shut Down Your Computer In C#
Shutdown computer in C#
shut down,restatrt remote computer‎
How do I programmatically shutdown the computer?
Remote Shutdown

Comments