473,408 Members | 2,734 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,408 software developers and data experts.

Process.RedirectStandardInput Question

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 to and from the application. Does
anybody know if i am missing something simple?

Thanks
Nov 16 '05 #1
4 8846
well there are a few things that could be happenning ... can you put up your
code ?
"Matt Osborne" <pr*****@stupidSpamer.net> wrote in message
news:4X*****************@newssvr27.news.prodigy.co m...
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 to and from the application. Does
anybody know if i am missing something simple?

Thanks

Nov 16 '05 #2
Sorry, here is the code

ProcessStartInfo startInfo = new ProcessStartInfo( "snap2.pif", "" );
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;

Thread.Sleep( 1000 );

Process snapToIt = Process.Start( startInfo );

StreamWriter writer = snapToIt.StandardInput;
StreamReader reader = snapToIt.StandardOutput;

writer = new StreamWriter( writer.BaseStream, new
System.Text.ASCIIEncoding() );

writer.AutoFlush = true;
writer.Write( (byte)'x' );
writer.Write( (byte)'x' );
writer.Write( (byte)'x' );
writer.Write( (byte)'x' );
writer.Write( (byte)13 );
writer.Write( (byte)'s' );
writer.Write( (byte)'i' );
writer.Write( (byte)'=' );
writer.Write( (byte)'p' );
writer.Write( (byte)'r' );
writer.Write( (byte)'o' );
writer.Write( (byte)'d' );
writer.Write( (byte)13 );
writer.Write( (byte)13 );
writer.Write( (char)121 );

As you can see i have tried using bytes instead of chars to be "more 16 bit
compliant" but to no avail. I also have tried changing the formatter to be
ascii and that hasn't helped.

Thanks for the help
"Greg Young" <gr********@planetbeach.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
well there are a few things that could be happenning ... can you put up your code ?
"Matt Osborne" <pr*****@stupidSpamer.net> wrote in message
news:4X*****************@newssvr27.news.prodigy.co m...
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 to and from the application. Does
anybody know if i am missing something simple?

Thanks


Nov 16 '05 #3
Try this

pDOSProcess.StartInfo.RedirectStandardOutput = true;
pDOSProcess.StartInfo.CreateNoWindow = true;
pDOSProcess.EnableRaisingEvents = true;
pDOSProcess.StartInfo.UseShellExecute = false;
//Add the exited event
pDOSProcess.Exited += new EventHandler(Process_exited);

pDOSProcess.Start();
private void Process_exited(object sender, System.EventArgs ea)
{
Process pro = (Process)sender;
//get the output.
string stdout= pro.StandardOutput.ReadToEnd();
}

--
Shak
(Houston)
"Matt Osborne" <pr*****@stupidSpamer.net> wrote in message
news:4X*****************@newssvr27.news.prodigy.co m...
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 to and from the application. Does
anybody know if i am missing something simple?

Thanks

Nov 16 '05 #4
Thanks for your post.

I tried your suggestion to no avail. To let you know more, I tried what i
had spawning "cmd" instead of my target app and i get a console window with
no output and i am able to read and write to its standard input and output
with out any problems. With this app I still can see the out put and it
apears that it is not recieving any input and when i manualy try to input
data it does not work either.

Any Ideas? The only think i can think of is that it doesn't work on 16 bit
applications

"David Williams" <Da***********@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
Try this instead (typed here so watch typos):

ProcessStartInfo startInfo = new ProcessStartInfo("snap2.pif", "");
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.UseShellExcute = false;
ThreadPool.QueueUserWorkItem(new WaitCallback(input));
ThreadPool.QueueUserWorkItem(new WaitCallback(output));
ThreadPool.QueueUserWorkItem(new WaitCallback(errors));
Process snapToIt = Process.Start(startInfo);
Process.WaitForExit();

...

static void input(Object state)
{
StreamWriter writer = snapToIt.StandardInput;
writer.AutoFlush = true;
...
}

static void output(Object state)
{
StreamReader reader = snapToIt.StandardOuput;
reader.ReadToEnd();
....
}

static void errors(Object state)
{
StreamReader reader = snapToIt.StandardError;
reader.ReadToEnd();
...
}
HTH
--
David Williams, VB.NET MVP
"Matt Osborne" wrote:
Sorry, here is the code

ProcessStartInfo startInfo = new ProcessStartInfo( "snap2.pif", "" ); startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;

Thread.Sleep( 1000 );

Process snapToIt = Process.Start( startInfo );

StreamWriter writer = snapToIt.StandardInput;
StreamReader reader = snapToIt.StandardOutput;

writer = new StreamWriter( writer.BaseStream, new
System.Text.ASCIIEncoding() );

writer.AutoFlush = true;
writer.Write( (byte)'x' );
writer.Write( (byte)'x' );
writer.Write( (byte)'x' );
writer.Write( (byte)'x' );
writer.Write( (byte)13 );
writer.Write( (byte)'s' );
writer.Write( (byte)'i' );
writer.Write( (byte)'=' );
writer.Write( (byte)'p' );
writer.Write( (byte)'r' );
writer.Write( (byte)'o' );
writer.Write( (byte)'d' );
writer.Write( (byte)13 );
writer.Write( (byte)13 );
writer.Write( (char)121 );

As you can see i have tried using bytes instead of chars to be "more 16 bit compliant" but to no avail. I also have tried changing the formatter to be ascii and that hasn't helped.

Thanks for the help
"Greg Young" <gr********@planetbeach.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
well there are a few things that could be happenning ... can you put up
your
code ?
"Matt Osborne" <pr*****@stupidSpamer.net> wrote in message
news:4X*****************@newssvr27.news.prodigy.co m...
> 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 to and from the application. Does > anybody know if i am missing something simple?
>
> Thanks
>
>


Nov 16 '05 #5

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: 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();...
2
by: ca___t | last post by:
Hi there : I want to start a consoneApplication using process.start method at web application server side.I have a question at this.Why the consoneApplication's process is start but not run...
3
by: - HAL9000 | last post by:
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...
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,...
1
by: solex | last post by:
Hello All, Hopefully someone has run into this error. I have written a class(source below) that launches a thread to monitor the StandardOutput of a System.Diagnostics.Process, in particular 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...
2
by: Darmac | last post by:
Hi, i'm new in this list so I don't know if anyone has asked this...but... I have a process (dos app instance) started like this: _procStartInfo = new ProcessStartInfo();...
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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.