EDN Admin
Well-known member
Hi Guys,
Im having trouble with a batch file that Im trying to run from my console application- I keep getting the error Unable to find the file specified even though I know the filepath is correct.
Any ideas? Ive pasted my code below:
<pre class="prettyprint int ExitCode;
ProcessStartInfo ProcessInfo;
Process process;
string command = @"""\******************DatabaseData ArchiveGraphsCurrencyGraphs.bat""";
ProcessInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
ProcessInfo.CreateNoWindow = true;
ProcessInfo.UseShellExecute = false;
// *** Redirect the output ***
ProcessInfo.RedirectStandardError = true;
ProcessInfo.RedirectStandardOutput = true;
process = Process.Start(ProcessInfo);
process.WaitForExit();
// *** Read the streams ***
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
ExitCode = process.ExitCode;
Console.WriteLine("output>>" + (String.IsNullOrEmpty(output) ? "(none)" : output));
Console.WriteLine("error>>" + (String.IsNullOrEmpty(error) ? "(none)" : error));
Console.WriteLine("ExitCode: " + ExitCode.ToString(), "ExecuteCommand");
process.Close();[/code]
<br/>
View the full article
Im having trouble with a batch file that Im trying to run from my console application- I keep getting the error Unable to find the file specified even though I know the filepath is correct.
Any ideas? Ive pasted my code below:
<pre class="prettyprint int ExitCode;
ProcessStartInfo ProcessInfo;
Process process;
string command = @"""\******************DatabaseData ArchiveGraphsCurrencyGraphs.bat""";
ProcessInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
ProcessInfo.CreateNoWindow = true;
ProcessInfo.UseShellExecute = false;
// *** Redirect the output ***
ProcessInfo.RedirectStandardError = true;
ProcessInfo.RedirectStandardOutput = true;
process = Process.Start(ProcessInfo);
process.WaitForExit();
// *** Read the streams ***
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
ExitCode = process.ExitCode;
Console.WriteLine("output>>" + (String.IsNullOrEmpty(output) ? "(none)" : output));
Console.WriteLine("error>>" + (String.IsNullOrEmpty(error) ? "(none)" : error));
Console.WriteLine("ExitCode: " + ExitCode.ToString(), "ExecuteCommand");
process.Close();[/code]
<br/>
View the full article