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

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

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

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

p.WaitForExit()

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

Return "" End Function

猜你在找的VB相关文章