Tuesday 12 January 2016

How to make Shutdown system Visual basic 2008 and 2010






This tutorial will show you how to create a Shutdown utility. Visual Basic 2008.
Open Visual Basic 2008 Express Edition.
Click on Project next to Create:



Click on Windows Form Application, and name the project "shutdown" and then click Ok.


Create a WindowsFormApplication and name it whatever you want. 

 


I’m using Visual Studio 2008 but it will work on express even if not studio.
Change the form name to whatever you want.
Set the maximize box and minimize box property to “false”. Change formborderstyle to FixedSingle.

 






 Add 3 Groupboxes and 3 buttons to the form.





Rename the ff:
 
                GroupBox1 = Shutdown              
  Groupbox2 = Restart     
 Groupbox3 = Log Off
Button1 = Click here to Shut down
 Button2= Click here to restart    
Button3=Click here to Log Off.

It should look like this.  


Now to add the code:
Double click on “Click here to shut down” button. Enter the code below:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Shell("shutdown -s")
 End Sub

Double Click on “Click here to Restart” button. Enter the code below:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Shell("shutdown -r")

    End Sub
Double Click on “Click here to logoff button”. Enter the code below:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        Shell("shutdown -l")

    End Sub

Debug and test it. It should work. NOTE: If you debug, it will shutdown, causing you to lose youwork if unsaved.

HAPPY CODING



No comments:

Post a Comment