tags:

views:

653

answers:

1

Hi folks,

i've got the following code which runs a bat file. the bat file then runs some .exe .. which does some stuff. The stuff takes aroun 5-10 seconds.

ProcessStartInfo start = new ProcessStartInfo
{
    Arguments = "\"" + newTargetFile + "\"" +
                " " +
                "\"" + originalFile.FullName + "\"",
    FileName = filename,
    WindowStyle = ProcessWindowStyle.Normal,
    CreateNoWindow = false,
    UseShellExecute = false
};

// Run the external process & wait for it to finish
using (Process proc = Process.Start(start))
{
    proc.WaitForExit();
}

What i'm trying to do is leave the command window open, even after the process terminates. Is there any way to do this?

Otherwise, can i get all the output of that window going to my debugger instead, so i don't need to worry about this window remaining?

cheers.

A: 

If you run the cmd interpreter with a /k argument and pass in the batch file name as the next argument, you should get what you're after. The /k argument tells Windows to leave the cmd interpreter open when it's done with whatever you tell it to do as the next argument.

You could certainly also use the RedirectStandardOutput property, but I think that would be more complicated in the end.

Daniel Straight
cheers. I also added 'pause' into the end of the .bat file :) that also did the trick :P
Pure.Krome