|
-
Apr 28th, 2011, 09:22 AM
#1
Thread Starter
New Member
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
-
Apr 28th, 2011, 09:32 AM
#2
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?
-
Apr 28th, 2011, 09:36 AM
#3
Thread Starter
New Member
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.
-
Apr 28th, 2011, 10:54 AM
#4
Thread Starter
New Member
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|