Skip to content

ProcessStartInfo ENVIRONMENT & UseShellExecute #2

Description

@charleslales

Hi,

You may have an issue on InternalRun(string cmd, string workingdir, bool bRedirectStreams).
You plan to setup env variable for starting new process this way...
p.StartInfo.EnvironmentVariables[key] = mEnvironmentVariables[key] as string;
.. but since you setup p.StartInfo.UseShellExecute = false; to redirect stderr/stdin, the process will in fact take env variable from current one.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/7f668b1c-e982-4d5b-b229-0b0e0cf9c249/processstartinfo-environment-amp-useshellexecute?forum=netfxbcl

This fix let me transfer proper cm.exe location that is not in global PATH env. variable..

                foreach (string key in mEnvironmentVariables.Keys)
                {
                    //p.StartInfo.EnvironmentVariables[key] =
                    //    mEnvironmentVariables[key] as string;

                    Environment.SetEnvironmentVariable(key, mEnvironmentVariables[key] as string);
                }

Regads,
Charles

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions