Console application question

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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.
 
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)
 
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.
 
Back
Top