process.* works in designer but not stand alone

  • Thread starter Thread starter Thom
  • Start date Start date
T

Thom

Hello - I have put together a little app that fires of a DOS program and
redirects the output of the DOS program to a textbox.
All is well and fine while I am in Visual Studio and run in debug. Redireted
DOS output displays properly in he textbox.
I am starting the DOS porgram with a process using .startinfo and friends.

Once I try to run the same executable from windows the redirected output no
longer displays in the textbox.

Has anyone else seen this and have any ideas?

Thanks,
Thom
 
Thom said:
redirects the output of the DOS program to a textbox.
All is well and fine while I am in Visual Studio and run in debug.
Redireted DOS output displays properly in he textbox.
I am starting the DOS porgram with a process using
.startinfo and friends.

Once I try to run the same executable from windows the
redirected output no longer displays in the textbox.

Hard to say without knowing anything about your code...
 
Sorry Herfried.....alot of this should look famiilar to you as I found bits
of it at
http://dotnet.mvps.org/dotnet/samples/miscsamples/downloads/RedirectConsole.zip

ElseIf Me.btnNetwork.Checked = True Then
mProcess = New Process
With mProcess.StartInfo
.FileName = "repstore.exe"
.Arguments = "3104"
.CreateNoWindow = True
.UseShellExecute = False
.RedirectStandardInput = True
.RedirectStandardOutput = True
End With
mProcess.Start()
Dim ts1 As ThreadStart = New ThreadStart(AddressOf StreamOutput)
mOutputStream = New Thread(ts1)
mOutputStream.Start()

blah blah other stuff....

Private Sub StreamOutput()
Dim strLine As String = mProcess.StandardOutput.ReadLine()
Try
Do While strLine.Length >= 0
If strLine.Length <> 0 Then
AddText(strLine)
End If
strLine = mProcess.StandardOutput.ReadLine()
Loop
Catch
End Try
End Sub

Private Sub AddText(ByVal strText As String)
mStrText = strText
Me.Invoke(CType(AddressOf Me.addTextToTextBox, MethodInvoker))
Dim fileNametoOpen, testChar As String
Dim found, intboxLength, intx, inty, intz As Integer
If strText.EndsWith(".txt") Then 'check for a textfile then put in
the textbox.
intboxLength = strText.Length
inty = intboxLength
For intx = intboxLength To 0 Step -1
found = strText.IndexOf(" ", inty)
If found > 0 Then
fileNametoOpen = strText.Substring(found + 1, intz - 1)
Call AddTextFromfile(fileNametoOpen)
Exit For
End If
intz = intz + 1
inty = inty - 1
Next intx
End If
End Sub

Private Sub addTextToTextBox()
Me.TextBox2.AppendText(mStrText & ControlChars.NewLine)
Me.TextBox2.SelectionStart = Me.TextBox2.Text.Length
End Sub
 
Thom said:
Sorry Herfried.....alot of this should look famiilar to you
as I found bits of it at
http://dotnet.mvps.org/dotnet/samples/miscsamples/downloads/RedirectConsole.zip

;-)

I am not able to see a difference when running the app inside the IDE or
outside the IDE, or switching between Debug and Releaser mode. What
application are you starting? Are you sure you don't access controls
directly from the different threads? You will have to use 'Control.Invoke'
or 'Control.BeginInvoke' to do that.
 
IF you are interested I can send the app to you. It is a little network
aware program for transferring data via a protocol called DICOM -- a medical
imaging thing.
The app fires and receives data but the data is not posted to the interface.
Let me know if you would like the app -- that may be the only way to see the
difference from within the IDE and outside of the IDE.

Thank you for your efforts. The app is about 421k in size.

Thom
 
Hello -- I chanced upon a little luck. I now have my app working properly.
I added .RedirectStandardError = True to my form load function

so now it is :
mProcess = New Process
With mProcess.StartInfo
.FileName = "repstore.exe"
.Arguments = "3104"
.UseShellExecute = False
.CreateNoWindow = True
.RedirectStandardOutput = True
.RedirectStandardError = True
.RedirectStandardInput = True
End With

Thank you for your help.

Thom

Thom said:
IF you are interested I can send the app to you. It is a little network
aware program for transferring data via a protocol called DICOM -- a medical
imaging thing.
The app fires and receives data but the data is not posted to the interface.
Let me know if you would like the app -- that may be the only way to see the
difference from within the IDE and outside of the IDE.

Thank you for your efforts. The app is about 421k in size.

Thom

http://dotnet.mvps.org/dotnet/samples/miscsamples/downloads/RedirectConsole.zip
 
Back
Top