Skip to content

Instantly share code, notes, and snippets.

@SteGriff
Last active February 1, 2017 14:02
Show Gist options
  • Select an option

  • Save SteGriff/87fe60165ecdf40149a7ad0e5676cdc0 to your computer and use it in GitHub Desktop.

Select an option

Save SteGriff/87fe60165ecdf40149a7ad0e5676cdc0 to your computer and use it in GitHub Desktop.
A tiny VB module to start a process and return its stdout text
Public Module ProcessReader
Public Function StartProcessAndGetOutput(filename As String, Optional args As String = "") As String
Dim startInfo As New ProcessStartInfo() With { _
.CreateNoWindow = True, _
.RedirectStandardOutput = True, _
.RedirectStandardInput = True, _
.UseShellExecute = False, _
.Arguments = args, _
.FileName = filename _
}
Dim p As New Process()
p.StartInfo = startInfo
p.Start()
p.WaitForExit()
Return p.StandardOutput.ReadToEnd()
End Function
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment