473,706 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 WriteConsoleInp ut, 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 3921

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

Similar topics

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 occurred both in CTRL-C type situations and CTRL-V. The latter being an extremely small percentage of the time. I think its system related and would like to CLEAR the contents of the clipboard prior to any CTRL-C operation. Is there a reliable
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 want to send a ctrl-C signal to this process from my application. Can anyone help me on this? Thanks, Carmen
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 postmessage(hwnd,WM_KEYDOWN,vk_control,code) postmessage(hwnd,WM_KEYDOWN,"A",code) postmessage(hwnd,WM_KEYUP,"A",code) postmessage(hwnd,WM_KEYUP,vk_control,code)
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 psi.RedirectStandardInput = True psi.RedirectStandardError = True psi.RedirectStandardOutput = True
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" myProcess.StartInfo.UseShellExecute = False myProcess.StartInfo.CreateNoWindow = True myProcess.StartInfo.RedirectStandardInput = True myProcess.StartInfo.RedirectStandardOutput = True
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 tried all ways to send ctrl-Z at end of my sms.but it takes this as a character or string only.also i tried with ascii value of ctrl-Z but of no use. i am able to see the transmitted commands on hyper-terminal through
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 process after the below code is executed? Dim process As New Process() Dim FileName As String = "externalprog.exe" Dim Arguments As String Arguments = "/c"
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 ASCII codes, but its not working with the ASCII codes for Ctrl+z.
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 System.Diagnostics.Process? I know I can simulate input through p.StandardInput.WriteLine, but I do not know what exactly input string represents "Ctrl+C". Thanks
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()); char temp = { Convert.ToChar(Keys.Control), Convert.ToChar(Keys.X) };
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.