|
-
Jun 25th, 2004, 11:50 AM
#1
Thread Starter
New Member
How to shutdown computer in vb.net
Try this code :
'Add System.Management Reference in your vb.net program
Imports System
Imports System.Management
Public Class clsWMI
Private obj As Object
Public Enum ShutDownOptions
LogOff = 0
SHUTDOWN = 1
REBOOT = 2
FORCE = 4
POWEROFF = 8
End Enum
Public WriteOnly Property ShutDown() As Integer
'Value should be ShutDownOptions
Set(ByVal Value As Integer)
For Each obj In GetObject("winmgmts:{(shutdown)}").ExecQuery("Select * from Win32_OperatingSystem")
obj.Win32Shutdown(Value)
Next
End Set
End Property
end Class
'Create a new form and add following code in calling procedure which will shutdown your comuter
Dim obj As New clsWMI
obj.ShutDown = obj.ShutDownOptions.SHUTDOWN + obj.ShutDownOptions.FORCE
It works Gr8 !!!!
Hiren
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|