Exemple #1
0
        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);
        }
Exemple #2
0
        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;
            }
Exemple #3
0
        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);
        }
Exemple #4
0
        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;
Exemple #10
0
 public static bool HasEnableWindowsErrorReportingDialog(this ChildProcessFlags flags) => (flags & ChildProcessFlags.EnableWindowsErrorReportingDialog) != 0;
Exemple #11
0
 public static bool HasDisableEnvironmentVariableInheritance(this ChildProcessFlags flags) => (flags & ChildProcessFlags.DisableEnvironmentVariableInheritance) != 0;
Exemple #12
0
 public static bool HasAttachToCurrentConsole(this ChildProcessFlags flags) => (flags & ChildProcessFlags.AttachToCurrentConsole) != 0;