Process p = new Process();
string vamppath = "set VAMP_PATH=D:";
string args = "echo %VAMP_PATH%";
p.StartInfo = new ProcessStartInfo("cmd", vamppath)
{
RedirectStandardOutput = true,
RedirectStandardInput = true,
UseShellExecute = false,
CreateNoWindow = true
};
//my alternate initialization code, but also does not work
//p.StartInfo.FileName = "cmd";
//p.StartInfo.Arguments = args;
//p.StartInfo.RedirectStandardOutput = true;
//p.StartInfo.RedirectStandardInput = true;
//p.StartInfo.UseShellExecute = false;
//p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine(vamppath);
string output = p.StandardOutput.ReadToEnd();
Console.WriteLine("Setting VAMP_PATH: " + output);
p.WaitForExit();
p.StandardInput.WriteLine(args);
output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
Console.WriteLine("Get VAMP_PATH: " + output);
I just do a simple set and get of a particular environment variable. When I do it manually in CMD it works properly. But when I execute the following commands using C# it does not.
What could be the problem? Thanks!


Sign In
Create Account

Back to top









