close dos window by program

every 30 seconds my app starts a console program which causes dos window opened. I want to close the dos window by my app before opening the new one. Please tell me how to do it. thanks.

by the way, is it possible to get a list of the files to be installed (including running dlls) after the setup program made?
[320 byte] By [lindawqu] at [2007-11-19 14:10:11]
# 1 Re: close dos window by program
Process.Start() will return a Process object which contains information about the process that is started by this method. Store the reference in an instance variable. you can attach an Exit event handler to the returned process object. When the eventhandler is called, set the process reference to null.

So, next time before you start another process, check the instance variable. If it is not null, call Kill() method on the Process object. It will terminate the existing one.

Another option is, when you start a new dos command, you could use "/c" keyword. When your console program exits, the command prompt will be automatically closed.

Process.Start("cmd.exe", "/c <yourconsoleapp>.exe");
poochi at 2007-11-9 1:52:46 >
# 2 Re: close dos window by program
If you just pass the name of a console app to Process.Start then the console window will close automatically when the app completes. If the app is not completing of its own accord then Process.Kill is the way to go, although you may want to think about whether you can change the console app to exit itself if that's possible. Also, you can use the ProcessStartInfo.CreateNoWindow property to prevent the console window being displayed.
jmcilhinney at 2007-11-9 1:53:44 >