Process RedirectStandardInput writing problem

  • Thread starter Thread starter - HAL9000
  • Start date Start date
H

- HAL9000

When I run the code below, nothing appears in the notepad window. I
am expecting the WriteLine text to be written into notepad but I get
nothing.

Also, I would expect the notepad window to be "Minimized" but it
isn't. Both WindowStyle and CreateNoWindow seem to have no effect.

I've already looked at:

http://msdn.microsoft.com/library/e...sStartInfoClassRedirectStandardInputTopic.asp


Thanks for you insight,
Forrest



Imports System.Diagnostics
Imports System.IO

Namespace AgentNameSpace

Class AgentClass

Shared Sub Main()

Dim agentProcess As New Process()

agentProcess.StartInfo.FileName = "notepad.exe"
agentProcess.StartInfo.UseShellExecute = False
agentProcess.StartInfo.CreateNoWindow = True
agentProcess.StartInfo.RedirectStandardInput = True
agentProcess.StartInfo.WindowStyle =
ProcessWindowStyle.Minimized
agentProcess.Start()

Dim agentStdInput As StreamWriter =
agentProcess.StandardInput

agentStdInput.WriteLine("some text")
agentStdInput.Flush()
agentStdInput.WriteLine("some more text...")
agentStdInput.Close()

End Sub

End Class

End Namespace
 
When I run the code below, nothing appears in the notepad window. I
am expecting the WriteLine text to be written into notepad but I get
nothing.

Also, I would expect the notepad window to be "Minimized" but it
isn't. Both WindowStyle and CreateNoWindow seem to have no effect.

I've already looked at:

http://msdn.microsoft.com/library/e...sStartInfoClassRedirectStandardInputTopic.asp


Thanks for you insight,
Forrest



Imports System.Diagnostics
Imports System.IO

Namespace AgentNameSpace

Class AgentClass

Shared Sub Main()

Dim agentProcess As New Process()

agentProcess.StartInfo.FileName = "notepad.exe"
agentProcess.StartInfo.UseShellExecute = False
agentProcess.StartInfo.CreateNoWindow = True
agentProcess.StartInfo.RedirectStandardInput = True
agentProcess.StartInfo.WindowStyle =
ProcessWindowStyle.Minimized
agentProcess.Start()

Dim agentStdInput As StreamWriter =
agentProcess.StandardInput

agentStdInput.WriteLine("some text")
agentStdInput.Flush()
agentStdInput.WriteLine("some more text...")
agentStdInput.Close()

End Sub

End Class

End Namespace

Normal GUI applications don't have a stdin and stdout to redirect. This
only works for console based applications. Your going to need to use
api calls to send text to the notepad window.
 
* - HAL9000 said:
When I run the code below, nothing appears in the notepad window. I
am expecting the WriteLine text to be written into notepad but I get
nothing.

Also, I would expect the notepad window to be "Minimized" but it
isn't. Both WindowStyle and CreateNoWindow seem to have no effect.

This will only work with console applications which provide the input
and output streams.
 
Thanks for responding so quickly Tom and Herfried...

API calls... does that mean I have to use "SendKeys" with the window
always in the foreground?

Thanks again,
Forrest
 
Back
Top