public static void ThrowExecutableNotFoundException(string fileName, ChildProcessFlags flags, Exception?innerException = null) { bool ignoreSearchPath = flags.HasIgnoreSearchPath(); var format = ignoreSearchPath ? "Executable not found: {0}" : "Executable not found on the search path: {0}"; throw new FileNotFoundException(string.Format(CultureInfo.InvariantCulture, format, fileName), fileName, innerException); }
public ChildProcessStartInfoInternal(ChildProcessStartInfo startInfo) { var flags = startInfo.Flags; FileName = startInfo.FileName; Arguments = startInfo.Arguments; WorkingDirectory = startInfo.WorkingDirectory; Flags = flags; CodePage = startInfo.CodePage; SearchPath = startInfo.SearchPath; StdInputRedirection = startInfo.StdInputRedirection; StdOutputRedirection = startInfo.StdOutputRedirection; StdErrorRedirection = startInfo.StdErrorRedirection; StdInputFile = startInfo.StdInputFile; StdOutputFile = startInfo.StdOutputFile; StdErrorFile = startInfo.StdErrorFile; StdInputHandle = startInfo.StdInputHandle; StdOutputHandle = startInfo.StdOutputHandle; StdErrorHandle = startInfo.StdErrorHandle; if (!flags.HasDisableEnvironmentVariableInheritance() && startInfo.CreationContext is null && startInfo.ExtraEnvironmentVariables.Count == 0) { UseCustomEnvironmentVariables = false; EnvironmentVariables = default; }
private static string ResolveExecutablePath(string fileName, ChildProcessFlags flags) { bool ignoreSearchPath = flags.HasIgnoreSearchPath(); var searchPath = ignoreSearchPath ? null : EnvironmentSearchPathCache.ResolveSearchPath(); var resolvedPath = SearchPathSearcher.FindExecutable(fileName, flags.HasAllowRelativeFileName(), searchPath); if (resolvedPath is null) { ThrowHelper.ThrowExecutableNotFoundException(fileName, flags); } return(resolvedPath); }
public ChildProcessStartInfoInternal(ChildProcessStartInfo startInfo) { FileName = startInfo.FileName; Arguments = startInfo.Arguments; WorkingDirectory = startInfo.WorkingDirectory; EnvironmentVariables = startInfo.EnvironmentVariables; Flags = startInfo.Flags; CodePage = startInfo.CodePage; SearchPath = startInfo.SearchPath; StdInputRedirection = startInfo.StdInputRedirection; StdOutputRedirection = startInfo.StdOutputRedirection; StdErrorRedirection = startInfo.StdErrorRedirection; StdInputFile = startInfo.StdInputFile; StdOutputFile = startInfo.StdOutputFile; StdErrorFile = startInfo.StdErrorFile; StdInputHandle = startInfo.StdInputHandle; StdOutputHandle = startInfo.StdOutputHandle; StdErrorHandle = startInfo.StdErrorHandle; // Additional parameters CreateNewConsole = Flags.HasCreateNewConsole() || !ConsolePal.HasConsoleWindow(); }
public static bool HasDisableArgumentQuoting(this ChildProcessFlags flags) => (flags & ChildProcessFlags.DisableArgumentQuoting) != 0;
public static bool HasCreateNewConsole(this ChildProcessFlags flags) => (flags & ChildProcessFlags.CreateNewConsole) != 0;
public static bool HasUseCustomCodePage(this ChildProcessFlags flags) => (flags & ChildProcessFlags.UseCustomCodePage) != 0;
public static bool HasAllowRelativeFileName(this ChildProcessFlags flags) => (flags & ChildProcessFlags.AllowRelativeFileName) != 0;
public static bool HasIgnoreSearchPath(this ChildProcessFlags flags) => (flags & ChildProcessFlags.IgnoreSearchPath) != 0;
public static bool HasEnableWindowsErrorReportingDialog(this ChildProcessFlags flags) => (flags & ChildProcessFlags.EnableWindowsErrorReportingDialog) != 0;
public static bool HasDisableEnvironmentVariableInheritance(this ChildProcessFlags flags) => (flags & ChildProcessFlags.DisableEnvironmentVariableInheritance) != 0;
public static bool HasAttachToCurrentConsole(this ChildProcessFlags flags) => (flags & ChildProcessFlags.AttachToCurrentConsole) != 0;