473,398 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Process RedirectStandardInput writing problem

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/en...InputTopic.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
Nov 20 '05 #1
3 3093
In article <lq********************************@4ax.com>, - HAL9000 wrote:
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/en...InputTopic.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.

--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #2
* - HAL9000 <gu***@mail.org> scripsit:
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.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
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
On Thu, 23 Oct 2003 10:20:45 -0500, - HAL9000 <gu***@mail.org> wrote:
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/en...InputTopic.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

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ask | last post by:
Hi NG I'm a bit new to programming c# and have a question regarding ftp by the command prompt. As far as I can see it should be possible to start a process and pipe command streams into it. But...
4
by: Matt Osborne | last post by:
Hello all. I have an application that i am writing to automate an older system. The system is based on a 16-bit DOS application. It apears to me that I am unable to redirect input and output...
4
by: jam | last post by:
Dear All, I have a command process running xcopy in console, and now I want to execute the program Rsync After the files are copied...how could i do?? Process p10=new Process();...
1
by: Bill Gregg | last post by:
I'm trying to decrypt a file using GPG and starting it via a system.diagnostics.process. The required steps are: 1) Launch the GPG.exe with the correct parameters indicating what file to...
0
by: Phillip Galey | last post by:
I'm trying to use the Process object to have RUNAS run DOS commands. I have no problem getting the Process object to run DOS commands and return the resulting text back to the program. However,...
0
by: wayne hamilton | last post by:
I'm having a problem Interacting with Command Line programs. I can read and write anything I want as long as I don't have to interact with a process once it's started. Originally I had been calling...
1
by: psathishreddy | last post by:
Hi I am writing a small programm which transfers file to a PDA device using IrDA. I am using irftp.exe to do that. The problem I have is, I am starting a Process to run irftp.exe. How do I...
5
by: =?Utf-8?B?Z215ZXJz?= | last post by:
Hello, I am attempting to start a cmd.exe process and pass several .vbs scripts (with additional parameters) and then read the output from the scripts and make "notes" in a DataTable (the...
11
by: Jon Davis | last post by:
Does anyone know why using System.Diagnostics.Process to "wrap" a console application does not always transmit the I/O, depending on what processes you're trying to "consume"? PowerShell, for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.