I'm working on an app that invokes external processes like so:
ProcessStartInfo startInfo = new ProcessStartInfo(PathToExecutable, Arguments){
ErrorDialog = false,
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true,
WorkingDirectory = WorkingDirectory
};
using (Process process = new Process()) {
process.StartInfo = startInfo;
process.Start();
process.BeginErrorReadLine();
process.BeginOutputReadLine();
process.WaitForExit();
return process.ExitCode;
}
One of the processes I'm calling depends on an environment variable that I'd rather not require my users to set. Is there any way to modify the environment variables that get sent to the external process? Ideally I'd be able to make them visible only to the process that's running, but if I have to programmatically set them system-wide, I'll settle for that (but, would UAC force me to run as administrator to do that?)
ProcessStartInfo.EnvironmentVariables is read only, so a lot of help that is...