471,325 Members | 1,685 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 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 3709

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by MLH | last post: by
3 posts views Thread by Str Noetika | last post: by
4 posts views Thread by F.C. | last post: by
1 post views Thread by Joey | last post: by
3 posts views Thread by zlf | last post: by
reply views Thread by rosydwin | 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.