标签:
Public Function ExecuteCmd(cmdstr As String)
Dim startInfo As New ProcessStartInfo("cmd.exe")
With startInfo
.Arguments = "/C " + cmdstr
.RedirectStandardError = True
.RedirectStandardOutput = True
.UseShellExecute = False
.CreateNoWindow = True
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()
Dim rsstr As String = ""
If (strOutput.Length <> 0) Then
rsstr = strOutput
ElseIf (strError.Length <> 0) Then
rsstr = strError
End If
rs.Text = rsstr
If Not InStr(rsstr, "错误") > 0 Then
IO.File.AppendAllText("Succeed.txt", txt_id.Text & txt_rs.Text & "," & txt_ps.Text & vbCrLf)
End If
btn.Enabled = True
Return rsstr
End Function
CMD 调用返回
标签:
原文地址:http://www.cnblogs.com/dvmu/p/5449494.html