jQuery and ASP.NET

December 20, 2009

Simplest way to Programmatically ShutDown or Restart your System using C# or VB.NET




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:

C#

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");
}

VB.NET

Private Sub btnShutDown_Click(ByVal sender As Object, ByVal e As EventArgs)
Process.Start("shutdown", "-s -f -t 0")
End Sub

Private Sub
btnRestart_Click(ByVal sender As Object, ByVal e As EventArgs)
Process.Start("shutdown", "-r -f -t 0")
End Sub


Bookmark this link on del.icio.us (saved by 0 users)

Did you like this post?
kick it on DotNetKicks.com
subscribe via rss subscribe via e-mail
print this post follow me on twitter
Others Also Read..

comments

0 Responses to "Simplest way to Programmatically ShutDown or Restart your System using C# or VB.NET"
 

Copyright 2010 All Rights Reserved DevCurry.com by Suprotim Agarwal