mkw007 2022-10-18 00:14 采纳率: 30%
浏览 21

VB.net 如何逐行获取CMD命令行的逐行输出

VB.net 调用命令行,无法获取逐行的输出
            Dim  P = New Process
            With P.StartInfo
                .FileName = "cmd.exe"
                .Arguments = "/c " & strCMD
                .UseShellExecute = False
                .RedirectStandardInput = True
                .RedirectStandardOutput = True
                .RedirectStandardError = True
                .CreateNoWindow = True
            End With
            P.Start()
        End If
        Do
            result = P.StandardOutput.ReadLine
        Loop While Not P.HasExited

img

  • 写回答

1条回答 默认 最新

  • 浪客 2022-10-18 08:50
    关注
    Do
        result = P.StandardOutput.ReadLine
        TextBox1.Text &= result & vbCrLf
        Application.DoEvents()
    Loop While Not P.HasExited
    
    评论

报告相同问题?

问题事件

  • 创建了问题 10月18日