yiannakop
June 8th, 2005, 06:23 AM
Hi. I need to run an exe using DOS inside my C# programm. I have found some things about running DOS command prompt, but they are about running internal DOS commands like dir,etc. I want to run an exe the syntax of which is iehv /stext c:\\urls.txt and another exe which uses perl and the syntax is perl extract.pl test.htm > test.out. I tried the follwoing code:
ProcessStartInfo startinfo;
Process p = null;
startinfo = new ProcessStartInfo("cmd.exe");
startinfo.RedirectStandardInput=true;
//startinfo.RedirectStandardOutput = true;
// don't exec with shellexecute api
startinfo.UseShellExecute = false;
// redirect stdout to this program
//startinfo.RedirectStandardOutput = true;
// don't open a cmd prompt window
//startinfo.CreateNoWindow = true;
// start cmd prompt, execute command
p = Process.Start(startinfo);
p.StandardInput.WriteLine(@"perl extract.pl test.htm > test.out");
p.StandardInput.WriteLine(@"exit");
//string output = p.StandardOutput.ReadToEnd();
//password.Text=output;
If I use an internal command like dir the command does execute. If I use the commands I need though, I get no output.
Can anyone help??
ProcessStartInfo startinfo;
Process p = null;
startinfo = new ProcessStartInfo("cmd.exe");
startinfo.RedirectStandardInput=true;
//startinfo.RedirectStandardOutput = true;
// don't exec with shellexecute api
startinfo.UseShellExecute = false;
// redirect stdout to this program
//startinfo.RedirectStandardOutput = true;
// don't open a cmd prompt window
//startinfo.CreateNoWindow = true;
// start cmd prompt, execute command
p = Process.Start(startinfo);
p.StandardInput.WriteLine(@"perl extract.pl test.htm > test.out");
p.StandardInput.WriteLine(@"exit");
//string output = p.StandardOutput.ReadToEnd();
//password.Text=output;
If I use an internal command like dir the command does execute. If I use the commands I need though, I get no output.
Can anyone help??