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


Reply With Quote

