473,395 Members | 1,393 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,395 software developers and data experts.

Standard Output from Process

I'm running a dos program via System.Diagnostics.Process.

The dos program is very picky about filenames and such, and so I want to
show the output to the user so they can verify it did what it was supposed
to do.

When I create my process like this it doesn't redirect the standard output:

Process prcs = new Process();
prcs.StartInfo.UseShellExecute = false;
prcs.StartInfo.FileName = @"n:\psoft\hr830\sqrfonts\fload.exe";
prcs.StartInfo.Arguments = @"loader.dat";
prcs.StartInfo.WorkingDirectory = @"n:\psoft\hr830\sqrfonts\";
prcs.StartInfo.RedirectStandardOutput = true;

prcs.Start();

while (!prcs.HasExited)
{
status.Text = "Loading SoftFonts...";
System.Threading.Thread.Sleep(1 * 1000);
}

output.Text = "Reading Standard Output..." //this is a text box
output.Text += prcs.StandardOutput.ReadToEnd();
output.Text += "Done.";
After running this code, in textbox named output, all I see is "Reading Standard
Output... Done."
But, if I change the process to this it works:

Process prcs = new Process();
prcs.StartInfo.UseShellExecute = false;
prcs.StartInfo.FileName = @"cmd.exe";
prcs.StartInfo.Arguments = @"/c fload.exe loader.dat";
prcs.StartInfo.WorkingDirectory = @"n:\psoft\hr830\sqrfonts\";
prcs.StartInfo.RedirectStandardOutput = true;

This seems like the wrong way to do it, but in a few other posts I saw that
this was the only way they could get the standard output to work. It seems
strange. Does it have to do with the app that I'm trying to run (fload.exe)
??
Nov 17 '05 #1
2 2453
Oh and the fload.exe program doesn't do what it is supposed to do when I
call it directly, but it does work when i call it via the cmd.exe

Nov 17 '05 #2
JAL
This may help.

http://www.geocities.com/jeff_louie/call_console.htm

Jeff
Brian wrote:
I'm running a dos program via System.Diagnostics.Process.

The dos program is very picky about filenames and such, and so I want to show the output to the user so they can verify it did what it was supposed to do.


Nov 17 '05 #3

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

Similar topics

3
by: Bo | last post by:
In my asp.net webservice application, I need to launch a DOS process as authorized users. To impersonate users, I use <impersonation = true> in my webconfig. I can't use Diagnostics.Process.Start,...
5
by: Christophe HELFER | last post by:
Hi, I would like to do this in VB Languague. I have an executable file in DOS mode. This executable returns informations and display them to the DOS window. Unfortunately, I have to process...
6
by: Alan Wang | last post by:
Hi All, My application puts standard output from command line(using process.start()) into a file on the hard disk then reads the info from that file after command has finished. The problem is...
4
by: Zenon | last post by:
I have a C# application which interacts with an HP UNIX box via PSFTP. I have run in to a problem where the maximum amount of characters I can redirect is 1024. This number leads me to believe...
1
by: Ivan | last post by:
Hello. I’m trying to capture standard output of the other process which is launched from my win app. I tried to do it with freopen function which captured content of the printf functions, but...
1
by: PiotrKolodziej | last post by:
Hi I have a process that output i need to save in file. Its a ping.exe. Iam sending 4 packets, and waiting for the process to exit. First i tried to add arguments to the proces in such a way: ...
3
by: mhmtzdmr | last post by:
Hi, I want to run an application and capture its standard output. But the following code does not generate any output. Can anyone see something wrong? Public Sub RunApp(ByVal myprocess As...
14
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in...
14
by: masaniparesh | last post by:
Hi Friends, The basic issue is "To read stdin and stdout in the same program" The following program is i have wrote using thread but i figured out that stdout is working but it is not working when...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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:
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
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...

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.