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, Action<Boolean> completionDelegate)
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.
completionDelegate
delegate that is called when execute completes. Passed true if success or false if timeout or failed
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, Action
See also:
Class ShellUtils© West Wind Technologies, 1996-2024 • Updated: 06/29/24
Comment or report problem with topic