J
John Grandy
I am using the following code to execute a batch file which contains
multiple commands, each on a separate line. Each command-line creates a
file. What I am finding is that only some of the files are being created ( 7
out of 11 ).
If I then run the batch file directly ( either by double-clicking, or
pasting its path into cmd.exe window ), all files are created ( 11 out of
11 ).
private void executeBatchFile(string pathBatchFile,
string pathWorkingDirectory,
Label outputDump)
{
ProcessStartInfo processStartInfo = new
ProcessStartInfo(pathBatchFile);
processStartInfo.RedirectStandardOutput = true;
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
processStartInfo.UseShellExecute = false;
processStartInfo.WorkingDirectory = pathWorkingDirectory;
Process process = Process.Start(processStartInfo);
process.WaitForExit(30000);
if (process.HasExited)
{
string output = process.StandardOutput.ReadToEnd();
outputDump.Text = output;
}
}
multiple commands, each on a separate line. Each command-line creates a
file. What I am finding is that only some of the files are being created ( 7
out of 11 ).
If I then run the batch file directly ( either by double-clicking, or
pasting its path into cmd.exe window ), all files are created ( 11 out of
11 ).
private void executeBatchFile(string pathBatchFile,
string pathWorkingDirectory,
Label outputDump)
{
ProcessStartInfo processStartInfo = new
ProcessStartInfo(pathBatchFile);
processStartInfo.RedirectStandardOutput = true;
processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
processStartInfo.UseShellExecute = false;
processStartInfo.WorkingDirectory = pathWorkingDirectory;
Process process = Process.Start(processStartInfo);
process.WaitForExit(30000);
if (process.HasExited)
{
string output = process.StandardOutput.ReadToEnd();
outputDump.Text = output;
}
}