清风的blog 优然探索

Vb.net强制关闭计算机

 Public Function DosCWindow(ByVal i As Integer) As String
        Dim S As String
        If i = 1 Then
            S = DosCommand("shutdown", "/f /l")
        ElseIf i = 2 Then
            S = DosCommand("shutdown", "/f /r")
        ElseIf i = 3 Then
            S = DosCommand("shutdown", "/f /s")
        End If
    End Function
    Private Function DosCommand(ByVal Str_Command As String, ByVal Str_Arguments As String) As String
        Dim Obj_Command As ProcessStartInfo = New ProcessStartInfo
        Dim Pro_Lob As Process = New Process
        Obj_Command.FileName = Str_Command
        Obj_Command.RedirectStandardInput = True
        Obj_Command.RedirectStandardOutput = True
        Obj_Command.RedirectStandardError = True
        Obj_Command.CreateNoWindow = True
        Obj_Command.UseShellExecute = False
        Obj_Command.Arguments = Str_Arguments
        Pro_Lob = Process.Start(Obj_Command)
        DosCommand = Pro_Lob.ToString
        Pro_Lob.Dispose()

    End Function

 

2008年9月11日 | 发布:admin | 分类:技术笔记 | 评论:0

发表留言: