Executes a Windows process with given command line parameters and captures console output into a string.
Pass in a String Action that receives output from StdOut and StdError as it is written (one line at a time).
public static int ExecuteProcess(string executable, string arguments, int timeoutMs, Action<String> writeDelegate, ProcessWindowStyle windowStyle)
Return Value
process exit code or 0 if run and forget. 1460 for time out. -1 on error
Parameters
executable
Executable to run
arguments
Command Line Parameters passed to executable
timeoutMs
Timeout of the process in milliseconds. Pass -1 to wait forever. Pass 0 to not wait.
writeDelegate
Delegate to let you capture streaming output of the executable to stdout and stderror.
windowStyle
Hidden, Normal etc.
Overloads:
public static int ExecuteProcess(string executable, string arguments, int timeoutMs, ProcessWindowStyle windowStyle)
public static int ExecuteProcess(string executable, string arguments, int timeoutMs, ref StringBuilder output, ProcessWindowStyle windowStyle)
See also:
Class ShellUtils© West Wind Technologies, 1996-2020 • Updated: 07/15/20
Comment or report problem with topic