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
myProcess.Start()
I want to send a CTRL-C event to the DOS app, since it's the only way to
interrupt it (unfortunately I'm not the author so I can't change this).
I tried to send a CTRL-C event using the "ConsoleCtrlEvent" API, with no
success. I tried both :
GenerateConsoleCtrlEvent(ConsoleCtrlEvent.CTRL_C, 0)
and
GenerateConsoleCtrlEvent(ConsoleCtrlEvent.CTRL_C, myprocess.id)
But none of them seems to work.
So if someone can help me, I'd be very grateful.
Thank you in advance !
F.C 4 4140
On Wed, 27 Oct 2004 14:47:48 +0200, F.C. wrote: Hi code gurus !
myProcess.StartInfo.RedirectStandardInput = True
I want to send a CTRL-C event to the DOS app, since it's the only way to interrupt it (unfortunately I'm not the author so I can't change this).
Since you have redirected the standard input, can't you just send a CTRL-C
character into the input stream?
I haven't tried this, but it may work.
Dim myStreamWriter As StreamWriter = myProcess.StandardInput
myStreamWriter.Write(Chr(3))
--
Chris
dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Hi Chris,
Thanks a lot for your reply. Unfortunately, I just tested and it didn't
work. I also tried chr(26), which is equivalent to Ctrl-Z (sometimes Unix
apps use this hotkey).
It was a smart suggestion though, but it seems I'm still stuck <:)
Regards
F.C.
"Chris Dunaway" <"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net"> a écrit dans
le message de news: 17*****************************@40tude.net... On Wed, 27 Oct 2004 14:47:48 +0200, F.C. wrote:
Hi code gurus !
myProcess.StartInfo.RedirectStandardInput = True
I want to send a CTRL-C event to the DOS app, since it's the only way to interrupt it (unfortunately I'm not the author so I can't change this).
Since you have redirected the standard input, can't you just send a CTRL-C character into the input stream?
I haven't tried this, but it may work.
Dim myStreamWriter As StreamWriter = myProcess.StandardInput myStreamWriter.Write(Chr(3))
-- Chris
dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and replace certain words in my E-Mail address.
On Wed, 27 Oct 2004 19:06:26 +0200, F.C. wrote: Thanks a lot for your reply. Unfortunately, I just tested and it didn't work. I also tried chr(26), which is equivalent to Ctrl-Z (sometimes Unix apps use this hotkey).
After writing to the stream, did you flush the stream? Perhaps that will
help to make sure all the data gets sent:
myStreamWriter.Flush()
--
Chris
dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Hmmm, I just tried this too, but it didn't work either. I'm not sure if the
application reacts to a caracter in its input stream, or to a direct
keypress, but it seems it's the second solution unfortunately.
I was hoping the GenerateConsoleCtrlEvent API would simulate this in a
trickiest manner, but I got no results at all.
Anyways, thanks again for your suggestions :)
Bye
F.C.
"Chris Dunaway" <"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net"> a écrit dans
le message de news: yd****************************@40tude.net... On Wed, 27 Oct 2004 19:06:26 +0200, F.C. wrote:
Thanks a lot for your reply. Unfortunately, I just tested and it didn't work. I also tried chr(26), which is equivalent to Ctrl-Z (sometimes Unix apps use this hotkey).
After writing to the stream, did you flush the stream? Perhaps that will help to make sure all the data gets sent:
myStreamWriter.Flush()
-- Chris
dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and replace certain words in my E-Mail address. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: jas |
last post by:
I have a basic client/server socket situation setup....where the server
accepts a connection and then waits for commands.
On the client side, I create a socket, connect to the server...then I...
|
by: Gary |
last post by:
I am trying to use the "System.Windows.Forms.SendKeys" class for triggering
the Ctrl+P key.
Syntax:
System.Windows.Forms.SendKeys.Send("^(P)");
This is not working ..what could be the...
|
by: Gary |
last post by:
Hi,
I am trying to use the "System.Windows.Forms.SendKeys" class for triggering
the Ctrl+P key.
Syntax:
System.Windows.Forms.SendKeys.Send("^(P)")
This is not working ..what could be the...
|
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...
|
by: B Loggins |
last post by:
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...
|
by: William Stacey [MVP] |
last post by:
How do you send Ctrl-C to a standard input stream? Just sending 03 does not
work.
--
William Stacey
|
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...
|
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...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |