471,354 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

close cmd window when process.startinfo closes

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
2 4983
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
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.

Similar topics

6 posts views Thread by clequieu | last post: by
2 posts views Thread by Alan T | last post: by
4 posts views Thread by =?Utf-8?B?SHVleQ==?= | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.