Console application question

G

Guest

How can I send the Enter or Return keystroke to a VB.Net 2005 console
application?
 
G

Guest

Apologies if the question was not clear, I know it sounds simplistic but...

I have tried launching another program from the console app using Process
and Process.StartInfo but the called app does not always work as expected
with the arguments passed in. When the arguments are run through a command
prompt it always behaves as expected.

I tried entering the call to the application with arguments using
console.writeline, but that does not launch the app.

I tried putting a console.writeline(vbcrlf) after the call, but no dice.

Any suggestions greatly appreciated, thanks.
 
G

Guest

VB said:
Apologies if the question was not clear, I know it sounds simplistic but...

I have tried launching another program from the console app using Process
and Process.StartInfo but the called app does not always work as expected
with the arguments passed in. When the arguments are run through a command
prompt it always behaves as expected.

I tried entering the call to the application with arguments using
console.writeline, but that does not launch the app.

I tried putting a console.writeline(vbcrlf) after the call, but no dice.

Any suggestions greatly appreciated, thanks.

Use the StandardInput property of the Process object to send input into
the application.
 
G

Guest

Use the StandardInput property of the Process object to send input into
the application.

I have tried the following code without success.

Dim proc As Process = New Process()
With proc.StartInfo
.FileName = "cmd.exe"
.UseShellExecute = False
.WindowStyle = ProcessWindowStyle.Normal
.CreateNoWindow = False
.RedirectStandardInput = True
.RedirectStandardOutput = True
.RedirectStandardError = True
End With
proc.Start()
Dim sIn As StreamWriter = proc.StandardInput
sIn.AutoFlush = True

sIn.WriteLine(Path.Combine(DPAPP_PATH, DPAPP) & " " & procArgs)
 
Z

zacks

I have tried the following code without success.

Dim proc As Process = New Process()
With proc.StartInfo
.FileName = "cmd.exe"
.UseShellExecute = False
.WindowStyle = ProcessWindowStyle.Normal
.CreateNoWindow = False
.RedirectStandardInput = True
.RedirectStandardOutput = True
.RedirectStandardError = True
End With
proc.Start()
Dim sIn As StreamWriter = proc.StandardInput
sIn.AutoFlush = True

sIn.WriteLine(Path.Combine(DPAPP_PATH, DPAPP) & " " & procArgs)

You need to create a StreamWriter and associate it with the sub-
processes standard input. Then, anything you write to the StreamWriter
will be sent to the subprocesses standard input stream.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top