473,396 Members | 1,734 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.

Cannot send Ctrl-C when wrapping cmd.exe

Hi everyone, thanks in advance fo any help on this issue.

I'm trying to "wrap" cmd.exe. That is, I'm redirecting StandardInput
and StandardOutput for a cmd.exe process and I'm sending StdOut to a
RichTextBox where I'm doing stuff to the text. I'm also passing the
characters typed to the RichTextBox to StandardInput for cmd.exe. This
is all working quite well, but the problem is that I cannot get cmd.exe
to process Ctrl-C correctly.

What I want to do is basically emulate the behavior of a user typing
CTRL+C in a cmd.exe window. That is, if there is a long-running batch
file or a child process (like ping.exe or tracert.exe) it will
interrupt the batch file or kill the child process.

Now if I P/Invoke over a SendCtrlEvent it Ctrl-C's cmd.exe itself,
which is not what I want. I basically want to insert the Ctrl+C
character into the input stream and have cmd.exe act as it normally
would. I've played with P/Invoking WriteConsoleInput, SetConsoleMode
(to character at a time mode), ...., all to no avail.

I just can't seem to be able to figure this out and I've searched all
over Usenet and the rest of the net for it. Am I missing something
simple here or am I really in for a lot of work?

Thanks again!

Dec 2 '05 #1
0 3897

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: MLH | last post by:
Sometimes I get a message saying "Cannot Open Clipboard". Its completely random, it seems and doesn't happen enough to get a complete handle on the situation at the time. I just know that it has...
1
by: carmen | last post by:
Hi, I have searched through msdn documentation, but couldnt figure this out. I have written a console application that starts a process using the Process class in system.diagnostics namespace. I...
3
by: Str Noetika | last post by:
Hi, How can I send ctrl keys (like ctrl A, ctrl C) from a VB application to another existing application (like word, excel...) ? I tried to send postmessages like...
2
by: ThomasG | last post by:
Hi, i've got a main (win-)application which starts a consoleapp to do some work: Dim psi As New ProcessStartInfo psi.UseShellExecute = False psi.CreateNoWindow = True...
4
by: F.C. | last post by:
Hi code gurus ! I'm creating a front end for a DOS application using VB .Net. I launch this DOS app using System.Diagnostics.Process : myProcess.StartInfo.FileName = "myapp.exe"...
2
by: abhay | last post by:
hi,i m interfacing gsm modem to my microcontroller.i need to send sms through it. i am using AT commands for that.the command to send sms (AT+ CMGS) terminates with ctrl-Z.now in my program i hav...
1
by: Joey | last post by:
I am using the below code to run a dos based program. While it is running you can hit ctrl-c to cancel the process. Does anyone know how I can send the same keystroke to the already runing...
0
by: misbahCU | last post by:
I am trying to make a script so that it can automate the basic functionality of the router like the logins and the password recovery. For this i am required to send the Ctrl+z, i tried using the...
3
by: zlf | last post by:
Hello I'm writing testcase for my console application. One testcase requires to test press Ctrl+C while the application is running. How to send Ctrl+C while running application through...
3
by: Blip | last post by:
Hello - I'm trying to wite these control characters to the serial port w/o success. I've tried sp.Write((Keys.ControlKey & Keys.X).ToString()); sp.Write((Keys.Control & Keys.X).ToString()); ...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.