If you break the problem into steps you have
1) Start the command processor
2) run vcvarsall.bat
3) run "tf help > tfshistory.txt"
So you actually want to run two commands not one and that will require the use of the "&" operator.
private static void RunCmds() {
const String batch1 = @"SetVars.cmd";
const String batch2 = @"ReadVars.cmd";
const String argsFormat = "/c {0} & {1} > output.txt";
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Environment.GetEnvironmentVariable("COMSPEC");
psi.Arguments = String.Format(argsFormat, batch1, batch2);
psi.UseShellExecute = false;
psi.CreateNoWindow = true;
Console.WriteLine("File: {0}", psi.FileName);
Console.WriteLine("Args: {0}", psi.Arguments);
Process p = Process.Start(psi);
p.WaitForExit();
Console.WriteLine(File.ReadAllText("output.txt"));
}
My batch files used for testing are
REM SetVars.cmd
SET ANIMAL=Chinchilla
SET CHARACTERISTIC=fluffy
@echo off
REM ReadVars.cmd
echo %ANIMAL%s are %CHARACTERISTIC%
and the console output is
File: C:\WINDOWS\system32\cmd.exe
Args: /c SetVars.cmd & ReadVars.cmd > output.txt
Chinchillas are fluffy
Ooh nice!