Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
SQL Server

How to Shut down the system Programmatically

Author: DevASP
Download Source Code :

This article is about how you can shut down the user computer from your application. In some situations if you want to shut down the user computer on some specific condition then this article is useful

Steps you will do. 

Start Visual Studio 2005 and create a new window application. 

Set the following properties of form.


Name = “frmMain”

Text = “Shut Down”

Drop a label control on form and set its following properties.


Text = “Its easy to shut down the user computer”

Name = “lblmsg”

Now drop a button control on the form and set its following properties.


Text = “Shut Down”

Name = “btn_shutdown”


Open the code window of your form and write the following code in the click event of the button which will shut down the user control safely and fast.



Dim t As Single


Dim objWMIService, objComputer As Object


objWMIService = GetObject("Winmgmts:{impersonationLevel=impersonate,(Debug,Shutdown)}")


For Each objComputer In objWMIService.InstancesOf("Win32_OperatingSystem")


t = objComputer.Win32Shutdown(2 + 4, 0)

If t <> 0 Then

            MsgBox("Error occurred!!!")

      End If



Run your application and click the button to shut down the computer.


NOTE! Save your data before clicking the button because you will lose unsaved data.

Article Comments
How to Shut down the system Programmatically

thank u 4 this

Posted on 11/8/2006 3:39:56 AM by sujith.vasudevan

this is article how to shot down system through the programm

Posted on 4/29/2007 12:41:35 AM by nagabhushanam

Add Article Comment:
Name :
Email Address :
Comments :
<< How we can Create Billboard with Lightening Effect Using VB.Net

Disclaimer - Privacy
© 2002-2017