473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 5092
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: chon | last post by:
I have an ASP page that is sent a file location as a parameter. It opens this file, loads the ADODB.Stream object and does a binary write to the page forcing the download dialog to appear. This...
1
by: gopal srinivasan | last post by:
I need to know how to close a parent modal window when child modal window opens, also i need to know the syntax for writing document on the modal window on the fly, like what we do in case of...
6
by: clequieu | last post by:
I have created a form. Within the form is a button to close the window on click and to validate as well. The close window works when it is a stand alone, but it does not work when it is embedded...
3
by: mcyi2mr3 | last post by:
Hi all I'm new to javascript and im trying to add a close button function to my certain pages of my site. I use this code: <a href='javascript:window.close();'>Close Window</a> to create a...
2
by: tomko | last post by:
Hi, My program uses the Process class to start a bat file that starts an exe. When I run my program inside Visual Studio (debug) the bat and exe run in the background (are not visible) and all...
2
by: Alan T | last post by:
I use Process.StartInfo to configure the process: Process myProcess = new Process(); myProcess.StartInfo.FileName = aProg; myProcess.StartInfo.Arguments = aArgument; ...
4
by: ceh | last post by:
Hi, I'm using c# vs 2005 win xp pro sp2. I create a cmd prompt with pInvoke via CreateProcessWithLogonW Taskmgr shows that cmd instance running as that user. I type set in that cmd window and it...
2
by: svbc | last post by:
Hi, I am facing a problem with refreshing parent: Parent window : A From A I am opening a child window B using...
4
by: =?Utf-8?B?SHVleQ==?= | last post by:
I need to hide the new window started from the code below. If I run as is, the window is visible. If I comment out the code that sets a different user, domain, and password the window is hidden...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.