
15-01-2009
|
 | Member | | Join Date: Apr 2008
Posts: 1,937
| |
| Shutdown, Restart, or Log Off your computer using VB.Net
Here's a quick code sample demonstrating how to use Process.Start in .NET to shutdown, restart, or log off your computer.
Simply design the form as image given below and use the given code.
The code for the whole program will be as follows Code: Public Class frmShutdown
Private Sub btnShutdown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShutdown.Click
System.Diagnostics.Process.Start("shutdown", "-s -t 00")
'This will make the computer Shutdown
End Sub
Private Sub btnRestart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRestart.Click
System.Diagnostics.Process.Start("shutdown", "-r -t 00")
'This will make the computer Restart
End Sub
Private Sub btnLogOff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogOff.Click
System.Diagnostics.Process.Start("shutdown", "-l -t 00")
'This will make the computer Log Off
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
End
'This will make the program to terminate(end the program)
End Sub
End Class |