By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,589 Members | 1,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,589 IT Pros & Developers. It's quick & easy.

close cmd window when process.startinfo closes

P: n/a
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.

Feb 24 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
"David" wrote:
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.

Feb 24 '06 #2

P: n/a
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.
"Mark R. Dawson" wrote:
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
"David" wrote:
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.

Feb 24 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.