close cmd window when process.startinfo closes

G

Guest

I'm opening a cmd window to run an ftp process. It's easy enough to close the
process (.close()), but the cmd window won't close unless I go out to the
window and type 'quit'.

How can I send a request to the cmd window to close?

Here's the code snippet that I'm using to make the call:

string strArg = "/c ftp.exe -v -n -s:" + strFile + " " + strHost + " > " +
strLogFile;
Process ftpProcess = new Process();
ftpProcess.StartInfo.FileName="cmd.exe";
ftpProcess.StartInfo.Arguments = strArg;
ftpProcess.StartInfo.CreateNoWindow=true;
ftpProcess.Start();

Below this line in the code I've tried a number of things, but they all
target the process and not the cmd window itself. The ftp process completes
successfully in just over a second.

thanks for any help.
 
G

Guest

Hi David,
do you want to show the command window at all, would keeping it hidden all
the time be acceptable? If so then you can set the WindowStyle property of
the ProcessStartInfo to Hidden and the command window will execute but won't
be displayed.

System.Diagnostics.ProcessStartInfo pi;
pi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden

Mark Dawson
http://www.markdawson.org
 
G

Guest

thanks for replying.
I did have that set, and once I get this working, I'll set it again.
Unfortunately, having it hidden isn't good enough, because it's still not
closed, and if I later try to access the file that the process creates, I get
an error stating that the file is being used by another application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top