redirecting output from external EXE file from VB.Net application

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