vb.net shell线程执行完成后再运行以后处理 函数

前端之家收集整理的这篇文章主要介绍了vb.net shell线程执行完成后再运行以后处理 函数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Public Shared Function ExecuteCmd(ByVal cmd As String) As String
Dim startInfo As New ProcessStartInfo("cmd.exe")
With startInfo
.Arguments = "/C " + cmd
.RedirectStandardError = True
.RedirectStandardOutput = True
.UseShellExecute = False
.CreateNoWindow = True
.WindowStyle = ProcessWindowStyle.Hidden
End With

Dim p As Process = Process.Start(startInfo)
Dim strOutput As String = p.StandardOutput.ReadToEnd()
Dim strError As String = p.StandardError.ReadToEnd()

p.WaitForExit()

If (strOutput.Length <> 0) Then
Return strOutput
ElseIf (strError.Length <> 0) Then
Return strError
End If

Return "" End Function

原文链接:https://www.f2er.com/vb/261266.html

猜你在找的VB相关文章