redirecting output from external EXE file from VB.Net application

G

Guest

Using VB.net standard 2003.

While in development environment can create process to execute an external EXE program and redirect output to "file.txt" using
System.Diagnostic.Process.Start. If I launch the created vbnetprogram.exe file, either debug or release, output form external EXE file is not written to "file.txt".

Any suggestions?
 
H

Herfried K. Wagner [MVP]

C

Cor

Hi Jerry,

Try this sample below

I hope this helps?

Cor

\\\p is Process (not procesStartinfo)
Dim sr As IO.StreamReader = p.StandardOutput
Dim sb As New System.Text.StringBuilder("")
Dim input As Integer = sr.Read
Do Until input = -1
sb.Append(ChrW(input))
input = sr.Read
Loop
Try
Dim sw As New IO.StreamWriter("FilePathName")
Try
sw.write(sb.toString)
sw.Close()
Catch ex As Exception
MessageBox.Show("ex.Tostring")
'Do an action
End Try
///
 
D

diebleng

Hi Try this with Vb.NET


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim myProcess As New Process
myProcess.StartInfo.UseShellExecute = True
myProcess.StartInfo.FileName = "c:\MyApp.exe"
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myProcess.Start()
myProcess.WaitForExit()
If myProcess.HasExited = True Then
MsgBox("It's done")
Else
MsgBox("not yet done")
End If

End Sub

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 

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