Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , ,

Sponsored Links



Shutdown, Restart, or Log Off your computer using VB.Net

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 15-01-2009
Praetor's Avatar
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
Reply With Quote
  #2  
Old 15-01-2009
Member
 
Join Date: Jan 2009
Posts: 9
Re: Shutdown, Restart, or Log Off your computer using VB.Net

Thanks,

I was searching for this type of code from long time.
and this really works fine.

Thanks again...........
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Shutdown, Restart, or Log Off your computer using VB.Net"
Thread Thread Starter Forum Replies Last Post
Automatic Restart After Shutdown Kyle Windows XP Support 13 12-12-2011 10:46 AM
Mortens ShutDown to Shutdown Computer at Desired Date And Time Soumen Tips & Tweaks 1 19-03-2009 11:32 AM
Windows does not Shutdown or Restart Curt Tips & Tweaks 0 08-11-2008 05:14 PM
Shortcut Keys to Shutdown and Restart your Computer Musrat Tips & Tweaks 1 26-09-2008 05:57 PM
Auto Shutdown and Restart John Windows Server Help 4 21-03-2008 11:36 PM


All times are GMT +5.5. The time now is 03:54 AM.