Option Strict Off

Public Class Shutdown
    Shared Sub Commit(ByVal mode As ShutdownMode)
        If mode = ShutdownMode.Standby Then
            SetSuspendState(False, False, False)
        ElseIf mode = ShutdownMode.Hibernate Then
            SetSuspendState(True, False, False)
        ElseIf mode <> ShutdownMode.Nothing Then
            For Each i As Object In GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * from Win32_OperatingSystem")
                i.Win32Shutdown(mode)
            Next
        End If
    End Sub

    Declare Function SetSuspendState Lib "powrprof.dll" (ByVal hibernate As Boolean, ByVal forceCritical As Boolean, ByVal disableWakeEvent As Boolean) As Boolean
End Class

Public Enum ShutdownMode
    [Nothing] = 5
    Standby = 4
    Shutdown = 1
    Hibernate = 3
    Logoff = 0
    Reboot = 2
End Enum