writing commands to Command Prompt Using VB
Hi all,
I am using Visual Studio 2010, VB to compile my program. My program include having to open a command prompt and writing a command to it. and display the output/errors in a textbox. But i can't seems to make it display it in a textbox and it opens ALOT of command prompts windows. Any help would be greatly appreaciated! Below is the my code:
Code:
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
Try
Dim P As New Process
With P
.StartInfo.FileName = "cmd.exe"
.StartInfo.RedirectStandardOutput = True
.StartInfo.UseShellExecute = False
.Start()
SendKeys.Send("julian.exe. -input mic -C julian.jconf" & "{enter}")
Output.Text &= .StandardOutput.ReadToEnd()
.WaitForExit()
End With
Catch ex As Exception
End Try
End Sub
Re: writing commands to Command Prompt Using VB
Welcome to VBForums.
Why not execute the julian.exe process directly? Is there a reason why you must first open up the command prompt, and then launch julian.exe from it?
Re: writing commands to Command Prompt Using VB
Hi,
I tried running julian.exe directly but it gave me this error
"A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll"
Maybe it's because julian.exe is a linux based program.
Re: writing commands to Command Prompt Using VB
When i took out this 2 lines :
vb Code:
.StartInfo.RedirectStandardOutput = True
.StartInfo.RedirectStandardError = True
It can open the cmd window and run smoothly.
But without the above 2 lines, how do i display the output of the cmd prompt in a textbox?