예제 #1
0
        public int BeginCreateProcess(
            string fileName,
            string arguments,
            string workingDirectory,
            bool createNoWindow,
            bool redirectStandardError,
            bool redirectStandardInput,
            bool redirectStandardOutput,
            Encoding standardErrorEncoding,
            Encoding standardOutputEncoding,
            StringDictionary environmentVariables,
            bool runAsUser,
            Nullable <int> sessionId,
            bool lowIntegrity,
            bool elevated,
            int redirectionBufferSize,
            out int threadId,
            out string stdOut,
            out string stdErr,
            out string stdIn)
        {
            //HACK: ProcessStartInfo is not marked serializable so we have to pass the data in pieces
            //create the process start info
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName               = fileName;
            startInfo.Arguments              = arguments;
            startInfo.WorkingDirectory       = workingDirectory;
            startInfo.CreateNoWindow         = createNoWindow;
            startInfo.RedirectStandardError  = redirectStandardError;
            startInfo.RedirectStandardInput  = redirectStandardInput;
            startInfo.RedirectStandardOutput = redirectStandardOutput;
            startInfo.StandardErrorEncoding  = standardErrorEncoding;
            startInfo.StandardOutputEncoding = standardOutputEncoding;

            startInfo.EnvironmentVariables.Clear();
            foreach (string key in environmentVariables.Keys)
            {
                startInfo.EnvironmentVariables[key] = environmentVariables[key];
            }

            return(ProcessHelper.BeginCreateProcess(startInfo, runAsUser, sessionId, lowIntegrity, elevated, out threadId, out stdOut, out stdErr, out stdIn, redirectionBufferSize));
        }