Tuesday, June 2, 2009

Shutdown PC Programe in VB.Net

Public Class Shutdown


    Private Sub ShutdownBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShutdownBtn.Click
        ShutdownPC()
    End Sub

    Private Sub ShutdownPC()
        Dim ShutdownArg As String = ""
        If ShutdownCheck.Checked = True Then
            System.Diagnostics.Process.Start("ShutDown", "-s -t " & Wait.Text)
        End If
        If RestartCheck.Checked = True Then
            System.Diagnostics.Process.Start("ShutDown", "-r -t " & Wait.Text)
        End If
        If LogOffCheck.Checked = True Then
            System.Diagnostics.Process.Start("ShutDown", "-l -t " & Wait.Text)
        End If
        If ShowGUICheck.Checked = True Then
            System.Diagnostics.Process.Start("ShutDown", "-i")
        End If

        'Arguments
        '-i                      Display GUI interface
        '-l                      Log off
        '-s                      Shutdown the computer
        '-r                      Shutdown and restart the computer
        '-a                      Abort a system shutdown
        '-f                      Forces all windows to close
        '-t xx                   Set timeout for shutdown to xx seconds
    End Sub

    Private Sub AbortBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AbortBtn.Click
        System.Diagnostics.Process.Start("ShutDown", "/a")
    End Sub
End Class
     

No comments:

Post a Comment