Simple Shutdown Utility – Visual Basic 2008

by: Liam Demafelix
Site: http://whizl287.multiply.com

This tutorial will show you how to create a Shutdown utility. visual basic 2008.

Open Visual Basic 2008 Express Edition. (If you don’t have the program click here to download it for free.)

Click on Project next to Create:

Click on Windows Form Application, and name the project “Media Player” 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 on the left.

Now to add the code:

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

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 highlighted code:

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 highlighted code:

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 your work if unsaved. 

Regard

Rismawan Junandia