Skip to main content

ProcessUtils

Async Process Helper

Assembly: ServiceStack.Common.dll
View Source
Declaration
public static class ProcessUtils

Methods

ConvertToCmdExec(ProcessStartInfo)

.NET Core / Win throws Win32Exception (193): The specified executable is not a valid application for this OS platform. This method converts it to a cmd.exe /c execute to workaround this

View Source
Declaration
public static ProcessStartInfo ConvertToCmdExec(this ProcessStartInfo startInfo)
Returns

System.Diagnostics.ProcessStartInfo

Parameters
TypeName
System.Diagnostics.ProcessStartInfostartInfo

FindExePath(String)

Returns path of executable if exists within PATH

View Source
Declaration
public static string FindExePath(string exeName)
Returns

System.String

Parameters
TypeName
System.StringexeName

RunShell(String, String)

Run the command with the OS's command runner

View Source
Declaration
public static string RunShell(string arguments, string workingDir = null)
Returns

System.String

Parameters
TypeName
System.Stringarguments
System.StringworkingDir

Run(String, String, String)

Run the process and return the Standard Output, any Standard Error output will throw an Exception

View Source
Declaration
public static string Run(string fileName, string arguments = null, string workingDir = null)
Returns

System.String

Parameters
TypeName
System.StringfileName
System.Stringarguments
System.StringworkingDir

CreateProcess(String, String, String)

View Source
Declaration
public static Process CreateProcess(string fileName, string arguments, string workingDir)
Returns

System.Diagnostics.Process

Parameters
TypeName
System.StringfileName
System.Stringarguments
System.StringworkingDir

RunShellAsync(String, String, Nullable<Int32>, Action<String>, Action<String>)

Run the command with the OS's command runner

View Source
Declaration
public static async Task RunShellAsync(string arguments, string workingDir = null, int? timeoutMs = null, Action<string> onOut = null, Action<string> onError = null)
Returns

System.Threading.Tasks.Task

Parameters
TypeName
System.Stringarguments
System.StringworkingDir
System.Nullable<System.Int32>timeoutMs
System.Action<System.String>onOut
System.Action<System.String>onError

RunAsync(ProcessStartInfo, Nullable<Int32>, Action<String>, Action<String>)

Run a Process asynchronously, returning entire captured process output, whilst streaming stdOut, stdErr callbacks

View Source
Declaration
public static async Task<ProcessResult> RunAsync(ProcessStartInfo startInfo, int? timeoutMs = null, Action<string> onOut = null, Action<string> onError = null)
Returns

System.Threading.Tasks.Task<ServiceStack.ProcessResult>

Parameters
TypeName
System.Diagnostics.ProcessStartInfostartInfo
System.Nullable<System.Int32>timeoutMs
System.Action<System.String>onOut
System.Action<System.String>onError

CreateErrorResult(Exception)

View Source
Declaration
public static ProcessResult CreateErrorResult(Exception e)
Returns

ServiceStack.ProcessResult

Parameters
TypeName
System.Exceptione