Run a DOS app from .NET

  • Thread starter Thread starter UJ
  • Start date Start date
U

UJ

I've got a DOS app I need to run (that requires no user input) from a .Net
and I need to wait for it to complete. How do I that?

TIA - J.
 
Use the System.Diagnostics.Process class:

Process p = Process.Start(@"dosapp.exe");
p.WaitForExit();

HTH, Jakob.
 
Thanks for the info.

What directory does this run in? I have a DOS app that has an .ini file that
goes with it so if I specify the directory to run the exe in, it doesn't
find the ini file. So what I really need to do is specify what directory to
run this in.

Here's an example I guess of what I need to do:

cd \program files\splat
runme.exe fred.input fred.output

Is there anyway I can do that?

TIA - J.
 
You can set the working directory of the new process using
ProcessStartInfo.WorkingDirectory and specify the arguments using
ProcessStartInfo.Arguments:

Process p = new Process();
p.StartInfo.WorkingDirectory = @"C:\program files\splat";
p.StartInfo.FileName = "runme.exe";
p.StartInfo.Arguments = "fred.input fred.output";
p.Start();
p.WaitForExit();

HTH, Jakob.
 
Back
Top